Download the PHP package melihovv/laravel-shopping-cart without Composer
On this page you can find all versions of the php package melihovv/laravel-shopping-cart. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download melihovv/laravel-shopping-cart
More information about melihovv/laravel-shopping-cart
Files in melihovv/laravel-shopping-cart
Package laravel-shopping-cart
Short Description Shopping cart package for laravel
License MIT
Informations about the package laravel-shopping-cart
Laravel Shopping Cart
Install
Install via composer
Publish configuration file and migrations
Run migrations
Overview
- Usage
- Instances
- Storage
- Coupons
Usage
Regiser facade in config/app.php
or
in the below examples.
The shopping cart gives you the following methods to use:
Cart::add()
Add an item to the shopping cart.
Cart::remove()
Remove the item with the specified unique id from the shopping cart. Unique id
is used to store items with the same $id
, but different $options
.
Cart::has()
Check if the shopping cart contains the item with the specified unique id.
Cart::get()
Get an item in the shopping cart by its unique id.
Cart::content()
Get all items in the shopping cart.
Cart::clear()
Clear the shopping cart.
Cart::count()
Return number of items in the shopping cart. This method does not summarize quantities of item. For example, there are 3 books and 1 iPhone in the shopping cart, so this method returns 2.
Cart::getTotal()
Return total price of all items in the shopping cart.
Instances
The package supports multiple instances of the cart. Some examples:
The default cart instance is called default
, so when you're not using
instances,Cart::content();
is the same as Cart::instance('default')->content()
.
Cart::instance()
Set current instance name.
Cart::currentInstance()
Get current instance name.
Storage
Currently there are two possible storage to persist shopping cart:
- Database
- Redis
You can choose one by specifying repository class name in config
In order to use redis storage you also need to install predis/predis
package.
Cart::store()
Persist current shopping cart instance to storage.
Cart::restore()
Restore shopping cart instance to storage.
Cart::destroy()
Remove shopping cart instance from storage.
Coupons
You can easily add discount coupons to shopping cart. Currently there are two types of coupons:
- FixedDiscountCoupon
- PercentDiscountCoupon
Related methods:
Cart::addCoupon()
Add coupon to cart.
Cart::coupons()
Returns all coupons.
Cart::getTotalWithCoupons()
Returns total price with applied coupons.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
All versions of laravel-shopping-cart with dependencies
ext-json Version *
illuminate/container Version ^6.0|^7.0|^8.0
illuminate/database Version ^6.0|^7.0|^8.0
illuminate/redis Version ^6.0|^7.0|^8.0
illuminate/support Version ^6.0|^7.0|^8.0