From 2c56062f9788c1ec3c4f5e8521333dc3e943171b Mon Sep 17 00:00:00 2001 From: Joel Male Date: Fri, 29 May 2026 14:09:15 +1000 Subject: [PATCH 1/8] fix: add @mixin and @method PHPDoc to CartFacade for PHPStan/Larastan support --- src/Facades/CartFacade.php | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/Facades/CartFacade.php b/src/Facades/CartFacade.php index 4ddccb7..f56f97f 100644 --- a/src/Facades/CartFacade.php +++ b/src/Facades/CartFacade.php @@ -3,10 +3,40 @@ namespace Wearepixel\Cart\Facades; use Illuminate\Support\Facades\Facade; +use Wearepixel\Cart\Cart; +use Wearepixel\Cart\CartCollection; +use Wearepixel\Cart\CartCondition; +use Wearepixel\Cart\CartConditionCollection; +use Wearepixel\Cart\ItemCollection; +/** + * @mixin Cart + * + * @method static ItemCollection|null get(int|string $itemId) + * @method static bool has(int|string $itemId) + * @method static void add(int|string $id, string $name, int|float $price, int $quantity, array $attributes = [], CartCondition|array $conditions = [], string $associatedModel = '') + * @method static bool update(int|string $id, array $data) + * @method static void remove(int|string $id) + * @method static void clear() + * @method static void clearItems() + * @method static Cart condition(array|CartCondition $condition) + * @method static CartConditionCollection|array getConditions(bool $array = false, bool $active = false) + * @method static CartCondition|null getCondition(string $conditionName) + * @method static CartConditionCollection getConditionsByType(string $type) + * @method static void removeConditionsByType(string $type) + * @method static void removeCartCondition(string $conditionName) + * @method static void clearItemConditions(int|string $itemId) + * @method static void clearAllConditions() + * @method static CartCollection getContent() + * @method static bool isEmpty() + * @method static int getTotalQuantity() + * @method static int|float|string getSubTotal(bool $formatted = true) + * @method static int|float|string getSubTotalWithoutConditions(bool $formatted = true) + * @method static int|float getTotal() + */ class CartFacade extends Facade { - protected static function getFacadeAccessor() + protected static function getFacadeAccessor(): string { return 'cart'; } From 34626eef5edbefd094f0ac8e7d3aa204b30b35b3 Mon Sep 17 00:00:00 2001 From: Joel Male Date: Fri, 29 May 2026 14:12:49 +1000 Subject: [PATCH 2/8] chore: bump version to 2.1.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7248399..119498d 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "wearepixel/laravel-cart", - "version": "2.1.1", + "version": "2.1.2", "description": "A cart implementation for Laravel", "keywords": [ "laravel", From 10ab30f4e884e3cda421e46cb797ad12baf6ad03 Mon Sep 17 00:00:00 2001 From: Joel Male Date: Fri, 29 May 2026 14:14:34 +1000 Subject: [PATCH 3/8] fix: correct add() @method signature to accept array input style --- src/Facades/CartFacade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Facades/CartFacade.php b/src/Facades/CartFacade.php index f56f97f..05e1eb9 100644 --- a/src/Facades/CartFacade.php +++ b/src/Facades/CartFacade.php @@ -14,7 +14,7 @@ * * @method static ItemCollection|null get(int|string $itemId) * @method static bool has(int|string $itemId) - * @method static void add(int|string $id, string $name, int|float $price, int $quantity, array $attributes = [], CartCondition|array $conditions = [], string $associatedModel = '') + * @method static self add(string|int|array $id, string|null $name = null, float|null $price = null, int|float|null $quantity = null, array $attributes = [], CartCondition|array $conditions = [], string|null $associatedModel = null) * @method static bool update(int|string $id, array $data) * @method static void remove(int|string $id) * @method static void clear() From e61ffae5fee73c12e48db395f49019921e6199f0 Mon Sep 17 00:00:00 2001 From: Joel Male Date: Fri, 29 May 2026 14:27:02 +1000 Subject: [PATCH 4/8] chore: bump version to 2.1.3 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 119498d..83660f8 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "wearepixel/laravel-cart", - "version": "2.1.2", + "version": "2.1.3", "description": "A cart implementation for Laravel", "keywords": [ "laravel", From 49959faace4e990c79e6ba35b685631f48f67734 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Jun 2026 10:48:04 +0000 Subject: [PATCH 5/8] chore(deps): bump actions/checkout in the actions group Bumps the actions group with 1 update: [actions/checkout](https://github.com/actions/checkout). Updates `actions/checkout` from 6.0.2 to 6.0.3 - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/de0fac2e4500dabe0009e67214ff5f5447ce83dd...df4cb1c069e1874edd31b4311f1884172cec0e10) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: 6.0.3 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: actions ... Signed-off-by: dependabot[bot] --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6c7685e..18092c3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Setup PHP uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2 From 834e211443d145ca74556b41c71cd9822734a456 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jun 2026 21:45:26 +0000 Subject: [PATCH 6/8] chore(deps): bump shivammathur/setup-php in the actions group Bumps the actions group with 1 update: [shivammathur/setup-php](https://github.com/shivammathur/setup-php). Updates `shivammathur/setup-php` from 2.37.1 to 2.37.2 - [Release notes](https://github.com/shivammathur/setup-php/releases) - [Commits](https://github.com/shivammathur/setup-php/compare/7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc...f3e473d116dcccaddc5834248c87452386958240) --- updated-dependencies: - dependency-name: shivammathur/setup-php dependency-version: 2.37.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: actions ... Signed-off-by: dependabot[bot] --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 18092c3..69ba19e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Setup PHP - uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2 + uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2 with: php-version: ${{ matrix.php }} extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, redis, memcached From 6ba50a1c48d1b5fa3a5f98b751dd6ea7036f97ca Mon Sep 17 00:00:00 2001 From: Joel Male Date: Sat, 13 Jun 2026 14:18:55 +1000 Subject: [PATCH 7/8] fix: prevent save() on array after clear() with database driver --- src/CartSession.php | 6 ++---- tests/Unit/DatabaseCartTest.php | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/CartSession.php b/src/CartSession.php index 5d6049d..8803e50 100644 --- a/src/CartSession.php +++ b/src/CartSession.php @@ -159,10 +159,8 @@ public function clear() $deleted = $this->session->delete(); - $this->session = [ - $this->itemsKey => [], - $this->conditionsKey => [], - ]; + $this->session[$this->itemsKey] = []; + $this->session[$this->conditionsKey] = []; return $deleted; } diff --git a/tests/Unit/DatabaseCartTest.php b/tests/Unit/DatabaseCartTest.php index ac8f37a..924ff07 100644 --- a/tests/Unit/DatabaseCartTest.php +++ b/tests/Unit/DatabaseCartTest.php @@ -123,4 +123,23 @@ expect($this->cart->getContent()->count())->toEqual(0, 'Cart content should be 0'); expect(MockCartModel::all()->count())->toEqual(0, 'The carts database table should have 0 rows'); }); + + test('can clear cart conditions after clearing the cart', function () { + $condition = new CartCondition([ + 'name' => '10% Off', + 'type' => 'coupon', + 'target' => 'subtotal', + 'value' => '-10%', + ]); + + $this->cart->add(1, 'Sample Item', 100.99, 2, []); + $this->cart->condition($condition); + + $this->cart->clear(); + + // This was throwing "Call to a member function save() on array" + // because clear() replaced $this->session with a plain array + expect(fn () => $this->cart->clearCartConditions())->not->toThrow(Error::class); + expect($this->cart->getConditions())->toBeEmpty(); + }); }); From 7427ce953a0867a0e54936565ade03744ab0aa5b Mon Sep 17 00:00:00 2001 From: Joel Male Date: Sat, 13 Jun 2026 14:19:39 +1000 Subject: [PATCH 8/8] chore: bump version to 2.1.4 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 83660f8..44cccf1 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "wearepixel/laravel-cart", - "version": "2.1.3", + "version": "2.1.4", "description": "A cart implementation for Laravel", "keywords": [ "laravel",