Commit Graph
72 Commits
Author SHA1 Message Date
Joel Male 45ef72894b fix: correct custom driver registration hint in cart:make:driver
The command told users to register their driver in config/cart.php
under "drivers", but CartManager has no such registration point for
custom drivers. The actual mechanism is Cart::extend() called from a
service provider's boot() method.
2026-08-04 12:06:58 +10:00
Joel Male 01189993f2 feat: add applies_to support for quantity-limited item conditions 2026-06-13 14:27:42 +10:00
Joel Male c50fc70688 fix: restore @mixin and @method PHPDoc on CartFacade for IDE and PHPStan support 2026-06-13 14:17:21 +10:00
Joel Male 3f1f5fb4d2 fix: add missing return type to getAssociatedModel 2026-06-13 14:09:29 +10:00
Joel Male 2ced1038af feat: add PHPStan level 5 with zero errors
- Install phpstan/phpstan, add phpstan.neon at level 5 targeting PHP 8.3
- Add phpstan-bootstrap.php stubs for Laravel helper functions (app,
  config, config_path, app_path, session) unavailable in standalone packages
- Fix CartCondition::setOrder() - removed incorrect @return int (method is void)
- Fix CartCondition::getCalculatedValue() - removed incorrect @return mixed PHPDoc
- Fix Cart::condition() - remove redundant instanceof check the type system already guarantees
- Fix Cart::fireEvent() - remove array_values() on already-list literal array
- Fix ItemCollection - add @property annotations for magic __get properties
- Fix ItemCollection::getAssociatedModel() - correct @return bool to @return mixed
- Fix ItemCollection::getConditions() - remove dead is_array && !instanceof check
- Fix Validator - add @method stub so PHPStan resolves make() through __callStatic
- Add ignoreErrors for trait.unused (HasCart designed for external Livewire use)
- Add ignoreErrors for round() mode mismatch (PHPStan 2.x PHP 8.4 stubs bug)
- Add phpstan step to CI (PHP 8.3 only, matches phpVersion config)
2026-06-06 16:02:16 +10:00
Joel Male 88a118d81b feat: make SessionDriver constructor args optional with app() defaults
new SessionDriver() now works out of the box in a Laravel app, resolving
the session and session ID from the container. Explicit args still work
as before. Also ignores .claude/ directory from version control.
2026-05-28 09:25:41 +10:00
Joel Male fd77347542 fix: validate class name input and check file write in Make commands
Add path traversal protection via PHP class name regex validation to all
four Make* commands, check file_put_contents() return value for write
failures, and remove the unnecessary \$defer = false property from
CartServiceProvider.
2026-05-27 21:49:08 +10:00
Joel Male ce51042edf feat: register Artisan commands in CartServiceProvider 2026-05-27 21:45:16 +10:00
Joel Male c2b2563cf1 feat: add cart:debug command 2026-05-27 21:44:47 +10:00
Joel Male 15d4397968 feat: add cart:make:driver command 2026-05-27 21:43:59 +10:00
Joel Male 76fba35643 feat: add cart:make:shipping command 2026-05-27 21:43:34 +10:00
Joel Male b8140166c9 feat: add cart:make:tax command 2026-05-27 21:43:14 +10:00
Joel Male fc16e6c877 feat: add cart:make:coupon command 2026-05-27 21:42:51 +10:00
Joel Male 731aaa070d feat: add cart:install command 2026-05-27 21:42:28 +10:00
Joel Male 0efd4378a8 feat: add HasCart trait and ShareCartWithInertia 2026-05-27 21:38:44 +10:00
Joel Male a485bfb6f0 refactor: use assertEqualsWithDelta for float comparisons, add @internal to fake()
Replace Assert::assertEquals with Assert::assertEqualsWithDelta (epsilon 0.0001)
in assertSubTotal, assertTotal, and assertTotalQuantity to avoid IEEE 754
floating-point equality pitfalls. Add @internal docblock to fake() to signal
it is test-only. Add regression test for consecutive withItems calls.
2026-05-27 21:35:49 +10:00
Joel Male 8d04d18b48 test: add withCoupon test and fix withItems ID collision 2026-05-27 21:33:35 +10:00
Joel Male 61863e0bd5 feat: add Cart::fake(), assertion methods, and CartFactory
Adds Cart::fake() which swaps the active driver to NullDriver and returns
a CartFactory fluent test builder. Adds assertion methods (assertContains,
assertCount, assertTotalQuantity, assertSubTotal, assertTotal,
assertConditionApplied, assertEmpty, assertNotEmpty) to Cart for use in
tests. CartFactory provides withItems(), withCondition(), and withCoupon()
as chainable helpers for seeding cart state.
2026-05-27 21:31:54 +10:00
Joel Male c3a734bd7f feat: add Cart::coupon(), Cart::tax(), Cart::shipping()
Proxy methods that accept first-class Coupon, TaxRule, and ShippingRate
objects and delegate to Cart::condition() via toCondition().
2026-05-27 21:27:23 +10:00
Joel Male 2513e07436 feat: add ShippingRate base class 2026-05-27 21:24:44 +10:00
Joel Male b5edbb8ec0 feat: add TaxRule base class 2026-05-27 21:24:09 +10:00
Joel Male 867daaf328 feat: add Coupon base class 2026-05-27 21:23:39 +10:00
Joel Male e41739c436 feat: add CartConditionable interface and first-class exceptions 2026-05-27 21:23:07 +10:00
Joel Male 4877911cdd fix: serialize conditions to arrays before storage; type \$events
- serializeConditions() now maps CartCondition objects to arrays via
  toArray() before passing to the driver, preventing json_encode()
  producing {} for object values in the DatabaseDriver
- Add Dispatcher type hint to \$events property and constructor parameter
- Add database round-trip test for cart-level conditions
- Fix CartConditionsTest to retrieve condition objects from the cart
  rather than relying on object-reference side-effects that no longer
  hold after proper serialization
2026-05-27 21:21:44 +10:00
Joel Male f3e5e958b7 fix: resolve Cart.php regressions after driver refactor
- Cast \$value to string in updateQuantityRelative() before passing to preg_match() and str_replace() to fix TypeError when integer quantities are passed
- Reconstruct ItemAttributeCollection and CartCondition objects from serialized arrays in getContent() so attribute property access (->size) and condition methods (.getName()) work correctly after deserialization
- Store CartCondition objects directly (not serialized to arrays) in saveConditions() to preserve object identity for parsedRawValue tracking via getCalculatedValue()
- Remove ->values() re-indexing from serializeItems() conditions serialization to preserve original condition array indices after partial removal
2026-05-27 21:16:07 +10:00
Joel Male adf4bca74f chore: remove CartSession (replaced by driver system) 2026-05-27 21:09:50 +10:00
Joel Male 9abf6a7a1b feat: update CartServiceProvider to use CartManager 2026-05-27 21:08:10 +10:00
Joel Male e0103aadaa refactor: update Cart to use CartDriver interface
Replace the v2 Cart implementation (which used CartSession directly) with
the v3 design that accepts a CartDriver contract via constructor injection.
Removes validateConfig(), replaces $this->session with $this->driver, adds
getDriver()/extend() helpers, serializes items/conditions through the driver,
and drops the unused setDecimals() method.
2026-05-27 21:06:22 +10:00
Joel Male 2f2d268e0f feat: add CartManager 2026-05-27 21:02:23 +10:00
Joel Male 71213d51f5 fix: null-safe json_decode in RedisDriver; add getSessionModel test to MultiDriverTest 2026-05-27 21:01:34 +10:00
Joel Male 83aa9a1431 feat: add MultiDriver 2026-05-27 20:59:45 +10:00
Joel Male 1705c23205 feat: add RedisDriver 2026-05-27 20:59:15 +10:00
Joel Male 4702cf98ab feat: add DatabaseDriver
Implements CartDriver for Eloquent-backed persistence using firstOrNew
pattern. Includes 9 unit tests covering CRUD, flush, clearItems, and
model retrieval.
2026-05-27 20:55:01 +10:00
Joel Male 8927ef08a0 fix: guard null writes in SessionDriver::setSessionKey 2026-05-27 20:53:19 +10:00
Joel Male c9f48d7e88 feat: add SessionDriver 2026-05-27 20:50:47 +10:00
Joel Male b3c4c53e63 feat: add NullDriver 2026-05-27 20:47:14 +10:00
Joel Male c9f3d76366 feat: add CartDriver interface 2026-05-27 20:46:48 +10:00
Joel Male 8f442f51e0 chore: migrate to wearepixel/laravel-cart 2026-03-24 14:04:48 +10:00
Joel Male a3161888aa chore: bump to v2.0.0 with PHP 8.3+ support and invalid item cleanup 2026-03-23 16:28:53 +10:00
Joel Male 4c02310bf7 feat: rough session re-implementation 2025-04-14 16:53:35 +10:00
Joel Male 4cf078277d feat: finish tests & docs 2025-02-25 16:54:03 +10:00
Joel Male 7adf5ecd1f feat: add tests and fix item level conditions for database storage 2025-02-25 16:31:42 +10:00
Joel Male 0f07b9ae8a feat: database support 2025-02-25 16:03:17 +10:00
Joel Male ec99aa0563 feat: clean up and starting documentation 2025-02-25 14:53:49 +10:00
Joel Male b92dce9ca4 wip: initial working database support 2025-02-25 11:47:10 +10:00
Joel Male 599051631c wip: rename package to joelwmale 2024-11-28 13:06:24 +10:00
Joel Male 5505f121c7 fix subtotal always being used 2024-09-23 07:45:59 +10:00
Joel Male 472d505041 wip: fix issue with conditions not being properly removed 2024-09-18 15:56:12 +10:00
Pixel Tech b7381573e8 Apply Laravel Pint
Signed-off-by: Pixel Tech <tech@wearepixel.com.au>
2024-09-08 02:21:01 +00:00
Joel Male d4d4df7d58 pint fixes 2024-09-08 12:20:36 +10:00