wexample / symfony-cart
Cart and catalog for Symfony: price snapshots, variations, schedules, stock reservation, checkout through symfony-payment
Requires
- php: >=8.5
- wexample/symfony-geo: >=5.0.0
- wexample/symfony-helpers: >=15.0.0
- wexample/symfony-money: >=5.0.0
- wexample/symfony-payment: >=3.0.0
Requires (Dev)
- phpunit/phpunit: ^13
- wexample/symfony-testing: >=2.0.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main
- 3.0.1
- 3.0.0
- 2.0.1
- 2.0.0
- 1.0.96
- 1.0.95
- 1.0.94
- 1.0.93
- 1.0.92
- 1.0.91
- 1.0.89
- 1.0.88
- 1.0.87
- 1.0.86
- 1.0.85
- 1.0.84
- 1.0.83
- 1.0.82
- 1.0.81
- 1.0.80
- 1.0.79
- 1.0.78
- 1.0.76
- 1.0.75
- 1.0.74
- 1.0.73
- 1.0.72
- 1.0.71
- 1.0.70
- 1.0.69
- 1.0.68
- 1.0.67
- 1.0.66
- 1.0.65
- 1.0.64
- 1.0.63
- 1.0.62
- 1.0.61
- 1.0.60
- 1.0.59
- 1.0.58
- 1.0.57
- 1.0.55
- 1.0.54
- 1.0.50
- 1.0.49
- 1.0.48
- 1.0.47
- 1.0.46
- 1.0.45
- 1.0.44
- 1.0.43
- 1.0.42
- 1.0.41
- 1.0.40
- 1.0.39
- 1.0.38
- 1.0.37
- 1.0.36
- 1.0.35
- 1.0.34
- 1.0.33
- 1.0.32
- 1.0.31
- 1.0.30
- 1.0.29
- 1.0.28
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.0.37
- 0.0.36
- 0.0.35
- 0.0.34
- 0.0.33
- 0.0.32
- 0.0.31
- 0.0.30
- 0.0.29
- 0.0.28
- 0.0.27
- 0.0.26
- 0.0.25
- 0.0.24
- 0.0.23
- 0.0.22
- 0.0.21
- 0.0.20
- 0.0.19
- 0.0.17
- 0.0.15
- 0.0.14
- 0.0.13
- 0.0.12
- 0.0.11
- 0.0.10
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
This package is auto-updated.
Last update: 2026-10-08 10:08:18 UTC
README
Version: 3.0.1
Filling a cart
$cart = $cartService->create(); // anonymous $cartService->addProduct($cart, $ticket, quantity: 2, schedule: $session, variations: [$presenter]); $cartService->addProduct($cart, $donation, amount: 4200); // free-amount product $cartService->attachOwner($cart, (string) $user->getId(), $user->getEmail());
Items copy the product's price when added: editing a product never changes existing carts. Variations replace the raw price (VAT still applies) or the final price. A product's maxPerCart keeps only the last items; PriceResolverInterface services set member or group prices.
Checkout
$initiation = $checkoutService->checkout($cart, 'card', $billingAddress); // client secret for the payment form
Checkout freezes the cart (waiting_payment), holds the stock of limited availabilities, and starts the payment — reusing an open one, replacing it when the total changed, completing a free cart at once. The payment's events then complete the cart (paid, CartPaidEvent, then each CartItemPaidHandlerInterface supporting the product type) or reopen it.
bin/console cart:expire --older-than=PT2H expires abandoned carts and gives their stock back (CartExpiredEvent). CartItemRepository::sumPaidSales() gives sales per product.
Table of Contents
- Filling a cart
- Checkout
- Architecture
- Integration in the Suite
- Dependencies
- Versioning & Compatibility Policy
- License
- About us
- Migration Notes
Architecture
src/Entity/Cart.php and src/Entity/CartItem.php use the symfony-money priced traits; an item keeps the product's price in priceBase and derives its effective prices from its variations. src/Entity/ProductAvailability.php rows are never deleted: what is left is the quantity minus confirmed and unexpired reservations (src/Entity/StockReservation.php). src/Service/StockService.php reserves inside a transaction with the availability row locked, and checks everything before persisting anything, so a refused reservation leaves the entity manager usable.
src/EventSubscriber/CartPaymentSubscriber.php is the only link with payments: the cart is a PayableInterface, the payment knows it by type and id, and a payment replaced by another never reopens the cart.
Integration in the Suite
This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.
Related Packages
The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.
Visit the Wexample Suite documentation for the complete package ecosystem.
Dependencies
- php: >=8.5
- wexample/symfony-helpers: >=15.0.0
- wexample/symfony-money: >=5.0.0
- wexample/symfony-geo: >=5.0.0
- wexample/symfony-payment: >=3.0.0
Versioning & Compatibility Policy
Wexample packages follow Semantic Versioning (SemVer):
- MAJOR: Breaking changes
- MINOR: New features, backward compatible
- PATCH: Bug fixes, backward compatible
We maintain backward compatibility within major versions and provide clear migration guides for breaking changes.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Free to use in both personal and commercial projects.
About us
Wexample stands as a cornerstone of the digital ecosystem — a collective of seasoned engineers, researchers, and creators driven by a relentless pursuit of technological excellence. More than a media platform, it has grown into a vibrant community where innovation meets craftsmanship, and where every line of code reflects a commitment to clarity, durability, and shared intelligence.
This packages suite embodies this spirit. Trusted by professionals and enthusiasts alike, it delivers a consistent, high-quality foundation for modern development — open, elegant, and battle-tested. Its reputation is built on years of collaboration, refinement, and rigorous attention to detail, making it a natural choice for those who demand both robustness and beauty in their tools.
Wexample cultivates a culture of mastery. Each package, each contribution carries the mark of a community that values precision, ethics, and innovation — a community proud to shape the future of digital craftsmanship.
Migration Notes
When upgrading between major versions, refer to the migration guides in the documentation.
Breaking changes are clearly documented with upgrade paths and examples.