Download the PHP package darthsoup/shoppingcart without Composer
On this page you can find all versions of the php package darthsoup/shoppingcart. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download darthsoup/shoppingcart
More information about darthsoup/shoppingcart
Files in darthsoup/shoppingcart
Package shoppingcart
Short Description Laravel 5 Shoppingcart
License MIT
Informations about the package shoppingcart
Laravel Cart
An easy shoppingcart implementation for Laravel > 6. Based on the work of Gloudemans\Shoppingcart.
Features
This package for shopping carts provides these features:
- [x] Cart items can have subitems
- [x] Custom hash algorithms for item identifiers
- [ ] Individual taxing for single items
- [ ] Database Support
Installation
To get the latest version, simply require the library using Composer.
Once installed, you'll need to publish the vendor assets
This will create cart.php
config file.
Usage
The cart package provides you the following methods to use:
Add Item
you also can make Items by make them manually
Update one Item
Get One Cart Item
Show Cart Content
Show the content of the Cart by returning the CartCollection
Empty the cart
Remove one Item or Subitem
Total Price of all Items
Item Count
SubItems
This package also includes the functionality to add Subitems by adding them to an additional collection in the Item
Add SubItem
The addSubItem
function works basically like add
but it accepts a parent row Id at the end to add an SubItem
to the item.
Remove SubItem
Just like removing normal ones, just include your subItem rowId
and it will be removed from the parent
Models
A new feature is associating a model with the items in the cart. Let's say you have a Product
model in your application. With the associate()
method, you can tell the cart that an item in the cart, is associated to the Product
model.
That way you can access your model right from the CartCollection
!
Here is an example:
Using the key model
to access the model that you associated.
Exceptions
The Cart package will throw exceptions if something goes wrong. This way it's easier to debug your code using the Cart package or to handle the error based on the type of exceptions. The Cart packages can throw the following exceptions:
Exception | Reason |
---|---|
InstanceException | When no instance is passed to the instance() method |
InvalidRowIdException | When the $rowId that got passed doesn't exists in the current cart |
InvalidQuantityException | When the quantity is outside the set limits |
ClassNotFoundException | When an class cannot found while association |
Events
The cart also has events build in. There are five events available for you to listen for.
Event | Fired | |
---|---|---|
cart.added($item) | When a item is added | |
cart.subitem.added($item) | When a sub item is added | |
cart.updated($rowId) | When an item in the cart is updated | |
cart.removed($rowId) | When an item is removed from the cart | |
cart.destroyed() | When the cart is destroyed |
Contributions
Please use Github for reporting bugs, and making comments or suggestions. See CONTRIBUTING.md for how to contribute changes.
All versions of shoppingcart with dependencies
illuminate/support Version ~6.0|~7.0|~8.0
illuminate/session Version ~6.0|~7.0|~8.0
illuminate/events Version ~6.0|~7.0|~8.0