chore: migrate to wearepixel/laravel-cart

This commit is contained in:
Joel Male
2026-03-24 14:04:48 +10:00
parent 6dfd0ce761
commit 8f442f51e0
31 changed files with 115 additions and 170 deletions
+11 -11
View File
@@ -1,12 +1,12 @@
<?php
namespace Joelwmale\Cart;
namespace Wearepixel\Cart;
use Joelwmale\Cart\Helpers\Helpers;
use Joelwmale\Cart\Validators\CartItemValidator;
use Joelwmale\Cart\Exceptions\InvalidItemException;
use Joelwmale\Cart\Exceptions\UnknownModelException;
use Joelwmale\Cart\Exceptions\InvalidConditionException;
use Wearepixel\Cart\Helpers\Helpers;
use Wearepixel\Cart\Validators\CartItemValidator;
use Wearepixel\Cart\Exceptions\InvalidItemException;
use Wearepixel\Cart\Exceptions\UnknownModelException;
use Wearepixel\Cart\Exceptions\InvalidConditionException;
class Cart
{
@@ -254,11 +254,11 @@ public function setConfig($config)
public function addItemCondition($productId, $itemCondition)
{
if ($product = $this->get($productId)) {
$conditionInstance = '\\Joelwmale\\Cart\\CartCondition';
$conditionInstance = '\\Wearepixel\\Cart\\CartCondition';
if ($itemCondition instanceof $conditionInstance) {
// we need to copy first to a temporary variable to hold the conditions
// to avoid hitting this error "Indirect modification of overloaded element of Joelwmale\Cart\ItemCollection has no effect"
// to avoid hitting this error "Indirect modification of overloaded element of Wearepixel\Cart\ItemCollection has no effect"
// this is due to laravel Collection instance that implements Array Access
// // see link for more info: http://stackoverflow.com/questions/20053269/indirect-modification-of-overloaded-element-of-splfixedarray-has-no-effect
$itemConditionTempHolder = $product['conditions'];
@@ -345,7 +345,7 @@ public function condition(array|CartCondition $condition): self
}
if (! $condition instanceof CartCondition) {
throw new InvalidConditionException('Argument 1 must be an instance of \'Joelwmale\Cart\CartCondition\'');
throw new InvalidConditionException('Argument 1 must be an instance of \'Wearepixel\Cart\CartCondition\'');
}
$conditions = $this->getConditions();
@@ -487,7 +487,7 @@ public function removeItemCondition($itemId, $conditionName)
// on the given condition name the user wants to remove, if so,
// lets just make $item['conditions'] an empty array as there's just 1 condition on it anyway
else {
$conditionInstance = 'Joelwmale\\Cart\\CartCondition';
$conditionInstance = 'Wearepixel\\Cart\\CartCondition';
if ($item['conditions'] instanceof $conditionInstance) {
if ($tempConditionsHolder->getName() == $conditionName) {
@@ -788,7 +788,7 @@ protected function itemHasConditions($item)
return count($item['conditions']) > 0;
}
$conditionInstance = 'Joelwmale\\Cart\\CartCondition';
$conditionInstance = 'Wearepixel\\Cart\\CartCondition';
if ($item['conditions'] instanceof $conditionInstance) {
return true;
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
namespace Joelwmale\Cart;
namespace Wearepixel\Cart;
use Illuminate\Support\Collection;
+4 -4
View File
@@ -1,10 +1,10 @@
<?php
namespace Joelwmale\Cart;
namespace Wearepixel\Cart;
use Joelwmale\Cart\Helpers\Helpers;
use Joelwmale\Cart\Validators\CartConditionValidator;
use Joelwmale\Cart\Exceptions\InvalidConditionException;
use Wearepixel\Cart\Helpers\Helpers;
use Wearepixel\Cart\Validators\CartConditionValidator;
use Wearepixel\Cart\Exceptions\InvalidConditionException;
class CartCondition
{
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
namespace Joelwmale\Cart;
namespace Wearepixel\Cart;
use Illuminate\Support\Collection;
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
namespace Joelwmale\Cart;
namespace Wearepixel\Cart;
use Illuminate\Support\ServiceProvider;
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
namespace Joelwmale\Cart;
namespace Wearepixel\Cart;
class CartSession
{
@@ -43,7 +43,7 @@ public function isInternalSession($session)
{
return in_array(is_object($session) ? get_class($session) : $session, [
'Illuminate\Session\SessionManager',
'Joelwmale\Cart\Tests\Helpers\SessionMock',
'Wearepixel\Cart\Tests\Helpers\SessionMock',
]);
}
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace Joelwmale\Cart\Exceptions;
namespace Wearepixel\Cart\Exceptions;
class InvalidConditionException extends \Exception {}
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace Joelwmale\Cart\Exceptions;
namespace Wearepixel\Cart\Exceptions;
class InvalidItemException extends \Exception {}
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace Joelwmale\Cart\Exceptions;
namespace Wearepixel\Cart\Exceptions;
class UnknownModelException extends \Exception {}
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
namespace Joelwmale\Cart\Facades;
namespace Wearepixel\Cart\Facades;
use Illuminate\Support\Facades\Facade;
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
namespace Joelwmale\Cart\Helpers;
namespace Wearepixel\Cart\Helpers;
class Helpers
{
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
namespace Joelwmale\Cart;
namespace Wearepixel\Cart;
use Illuminate\Support\Collection;
+3 -3
View File
@@ -1,9 +1,9 @@
<?php
namespace Joelwmale\Cart;
namespace Wearepixel\Cart;
use Illuminate\Support\Collection;
use Joelwmale\Cart\Helpers\Helpers;
use Wearepixel\Cart\Helpers\Helpers;
class ItemCollection extends Collection
{
@@ -72,7 +72,7 @@ public function hasConditions()
if (is_array($this['conditions'])) {
return count($this['conditions']) > 0;
}
$conditionInstance = 'Joelwmale\\Cart\\CartCondition';
$conditionInstance = 'Wearepixel\\Cart\\CartCondition';
if ($this['conditions'] instanceof $conditionInstance) {
return true;
}
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace Joelwmale\Cart\Validators;
namespace Wearepixel\Cart\Validators;
class CartConditionValidator extends Validator {}
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace Joelwmale\Cart\Validators;
namespace Wearepixel\Cart\Validators;
class CartItemValidator extends Validator {}
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
namespace Joelwmale\Cart\Validators;
namespace Wearepixel\Cart\Validators;
use Illuminate\Validation\Factory;
use Illuminate\Filesystem\Filesystem;