Download the PHP package devanych/yii2-cart without Composer
On this page you can find all versions of the php package devanych/yii2-cart. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download devanych/yii2-cart
More information about devanych/yii2-cart
Files in devanych/yii2-cart
Informations about the package yii2-cart
Yii2 shopping cart
This extension adds shopping cart for Yii framework 2.0
Guide with a detailed description in Russian language here.
Installation
The preferred way to install this extension is through Composer
Either run
or add
to the require
section of your composer.json
file.
Configuration
Configure the cart
component (default values are shown):
In addition to devanych\cart\storage\SessionStorage
, there is also devanych\cart\storage\CookieStorage
and devanych\cart\storage\DbSessionStorage
. It is possible to create your own storage, you need to implement the interface devanych\cart\storage\StorageInterface
.
DbSessionStorage
uses SessionStorage
for unauthorized users and database for authorized.
If you use the
devanych\cart\storage\DbSessionStorage
asstorageClass
then you need to apply the following migration:
devanych\cart\calculators\SimpleCalculator
produces the usual calculation of the total cost and total quantity of items in the cart. If you need to make a calculation with discounts or something else, you can create your own calculator by implementing the interface devanych\cart\calculators\CalculatorInterface
.
Setting up the params
array:
-
key
- For Session and Cookie. -
expire
- Cookie life time. -
productClass
- Product class is an ActiveRecord model. -
productFieldId
- Name of the product modelid
field. productFieldPrice
- Name of the product modelprice
field.
Supporting multiple shopping carts to same website:
Usage
You can get the shopping cart component anywhere in the app using Yii::$app->cart
.
Using cart:
Using cart items:
By using method
getProduct()
, you have access to all the properties and methods of the product.