Download the PHP package johannesschobel/laravel-shoppingcart without Composer
On this page you can find all versions of the php package johannesschobel/laravel-shoppingcart. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download johannesschobel/laravel-shoppingcart
More information about johannesschobel/laravel-shoppingcart
Files in johannesschobel/laravel-shoppingcart
Package laravel-shoppingcart
Short Description A Shopping Cart Implementation for Laravel
License MIT
Informations about the package laravel-shoppingcart
laravel-shoppingcart
Provides an invitation mechanism for Laravel applications. Note that this package does not handle, how the invitation is sent to the user (e.g., via email).
Installation
First, add the respective line to your composer file
and run composer install
to install the new component.
Then add respective ServiceProvider
from the package to your config/app.php
configuration file, like this:
and register the Facade
Then, you simply add the provided migration
file using the following command:
and then you migrate your database using
If you want, you can overwrite the basic configuration of this package using the following command:
This will copy the shoppingcart
configuration file to your config
folder. Using this file, you can
customize the various parameters of the package. Currently, not many are available, however, I will be adding more
and more ;)
Usage
The ShoppingCart
Facade provides some neat methods to deal with the shopping cart in general. These methods are:
LOAD a ShoppingCart from the database
Load the cart with the identifier
and name
from the database. If no name
is provided, the default name default
will be used. If no cart exists, an empty cart will be returned. This cart remains temporary as long as no items are
stored.
CLEAR a ShoppingCart
Removes the current instance of the cart from the database.
ADD Items to the Cart
This method allows for adding items to the cart. The basic usage allows you to directly specify the item you want to set. For example
would add 10 "Basic T-Shirts", each costs 9.99 EUR to the cart. The customer has specified a color and size.
You may, however, add the Buyable
interface to your products in order to simplify this process. This will require you
to implement additional methods on the model (you can add the CanBePurchased
Trait in order to make a "best guess").
This would allow you to just add a specific product:
would result in the same cart as above. However, the id
, name
, price
and uri
are directly taken from the model!
REMOVE Items from the Cart
To remove an item from the shopping cart you need to have its rowId
. This rowId
can be obtained, for example, via
the ShoppingCart::load()
or ShoppingCart::getContent()
method.
UPDATE Items in the Cart
allows you to update a given row in the cart. This rowId
can be obtained, for example, via the
ShoppingCart::load()
or ShoppingCart::getContent()
method.
would update the quantity and options of the item (e.g., the product to be purchased shall be 'red' instead of 'black').
Items / Price / Taxes
The Cart also provides methods to
- get the amount of items in the cart =>
getItemCount()
- get the content of the cart. This returns all items in the cart =>
getContent()
- get the value of the current cart
- get the taxes of the cart =>
getTaxes()
- get total (value including taxes) =>
getTotal()
- get subtotal (value without taxes) =>
getSubTotal()
- get the taxes of the cart =>
- get the "associated"
Buyable
model =>resolveModel()