New version 0.9 has been released! Jun 16, 2015

Shopcart module


Shopcart module helps you to create shopping cart on frontend and orders control on backend.


use yii\easyii\modules\shopcart\api\Shopcart;

Public functions

array Shopcart::goods()
Returns array of GoodObject added to shopping cart by user

object Shopcart::order( $id )
$id integer Order identifier
Returns OrderObject or null if not found.

string Shopcart::form( $options = [] )
$options array
  • successUrl (string) - redirect url on success.
  • errorUrl (string) - redirect url on error.
Returns fully worked standalone html form to complete order.

array Shopcart::add( $item_id, $count = 1, $increaseOnDuplicate = true )
Add catalog item to shopping cart
$item_id integer Catalog item identifier
$count integer Count of items added to shopcart
$increaseOnDuplicate boolean Increase goods count on duplicate item added
Returns Result array + order_id, good_id, item_id, options, discount

array Shopcart::remove( $good_id )
Remove goods from shopping cart
$good_id integer Goods id
Returns Result array + good_id, order_id

void Shopcart::update( $goods )
Update goods count in shopping cart
$goods array Format [$good_id => $new_count, 1 => 3]

array Shopcart::send( $data )
Complete user order and send it to admin panel
$data array Data will be set to Order details(name, address, email, phone, comment)
Returns Result array + order_id, access_token

integer Shopcart::cost()
Returns total cost of current shopping cart


Public Properties

$name string User name
$email string User E-mail
$address string User delivery address
$phone string User phone
$access_token string Secret token to access order
$goods array Array of GoodObject
$cost integer Total cost of order
$status string Status name of order
$model yii\db\ActiveRecord Order ActiveRecord object


Public Properties

$order_id integer Order identifier
$item_id integer Catalog item identifier
$options string Some possible options like color or size
$count integer Goods count
$item_id integer Catalog item identifier
$item object ItemObject
$slug string Catalog item slug
$category_id integer Catalog category identifier
$discount integer Item discount
$price integer Catalog item price with discount
$old_price integer Old item price if discount > 0
$model yii\db\ActiveRecord Good ActiveRecord object