Download the PHP package abo3adel/shoppingcart without Composer
On this page you can find all versions of the php package abo3adel/shoppingcart. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download abo3adel/shoppingcart
More information about abo3adel/shoppingcart
Files in abo3adel/shoppingcart
Package shoppingcart
Short Description a simple yet powerful and highly customized laravel shopping cart
License MIT
Informations about the package shoppingcart
Shopping Cart
a simple yet powerful and highly customized laravel shopping cart.
Highly inspired by LaravelShoppingcart
Demo shopping-cart
Features
- Multiple cart instances
- Multiple Buyable models
- Discount && Tax
- configure up to 2 colums in cart item
- Guest cart items && user cart items
- It`s more like the Laravel way
Requirements
- PHP 7.1+ (tested in 7.2+)
- Laravel 5.5
How It works
This package use sessions and database, it will save cart items into session for guests and then merge these items when user logIn and save it into database, while user is loggedIn items will be saved into database
Installation
-
require
-
Import config file and migration and migrate
-
configure before migrate
- Add a trait and interface (required) to the model that can be bought
Overview
- Usage
- Instances
- Helpers
- Models
- Bonus
- Exceptions
- Events
- Commands
- Example
- Tests
- Contribution
- License
Usage
you can use the facade or the helper function
Cart::add()
return the newly saved item
Cart::find()
return the cart item if found || else null
Cart::update()
return boolean
Cart::delete()
return boolean
Cart::has()
return boolean
Cart::content()
return collection of cart items for current instance. all collection methods allowed see Collections
Cart::destroy()
delete all items for current instance
count of deleted items
Instances
Cart stays in the last set instance if you don't set a different one
Helpers
Cart::total()
get the sum of all items sub_total (qty * price)
Cart::totalPrice()
the sum of all items price
Cart::totalQty()
the sum of all items qty
Cart::subTotal()
get the total minus tax percentage
Cart::setTax()
set tax percentage for current instance only does not affect the configured value
Cart::getTax()
retrieve current tax percentage
Cart::increments()
increase item qty
Cart::decrements()
decrease item qty
Models
CartItem
Buyable
Bonus
Manage another user cart items
Cart stays in the last set User if you don't set a different one
Cart::checkBuyableStockAmount()
this will delete cart items which buyable is out of stock and lower items qty if it exceeded buyable qty
Refresh Items Buyable Object
only required in session this will update the buyable object with latest changes you can use this to check if item buyable still in stock
Exceptions
Exception | Reason |
---|---|
InvalidModelException | Provided buyable model is missing required attributes (getPrice() - id) |
ItemAlreadyExistsException | trying to add new item that was already added |
ItemNotFoundException | trying to update or delete an item that is not found |
Events
Event | Fired | Parameter |
---|---|---|
CartItemAdded | When an item was added to the cart. | the CartItem |
CartItemUpdated | When an item was updated | the CartItem |
CartItemRemoved | when an item was removed | the CartItem |
CartInstanceDestroyed | when all items for this instance is deleted | instance |
Commands
this will delete old cart item from database older than configured
deleteAfter
value
Schedule the RemoveOldItemsCommand
Example
Tests
Contribution
Contributions are welcome and will be fully credited. see CONTRIBUTING.md
License
This project is licensed under the MIT License - see the LICENSE file for details