|Classes of Tomas Saghy||>||PHP Cart Page||>||README.md||>||Download|
PHP library providing basic shopping cart functionality.
Install the latest version using
Or add to your composer.json file as a requirement:
Constructor takes three configuration parameters: * context data that are passed to each added cart item (you can pass i.e. customer id to resolve custom price) * true when listing gross prices, false for net prices (see nice explanation) * number of decimals for rounding
All of them can be set separately.
Manipulating cart items
Items can be accessed by their cart id (provided by getCartId method).
Batch cart items manipulation
Cart can be cleared using clear() method. Items can be set using setItems() method. Please note that setItems will call clear. All items have to implement CartItemInterface.
Items can be fetched using getItems or by type using getItemsByType.
Cart works with Decimal class (see litipk/php-bignumbers). You can access subtotal (without VAT), taxes (array of amounts for all rates) and total (subtotal + taxes).
Totals can be also count by type:
Getting weight (since 1.4)
As of 1.4 item implementing WeightedCartItemInterface can be added to cart, so cart can count total weight. Weight can be counted by type using same format as for counting totals.
You can run the unit tests with the following command: