PHPackages                             sya/yii2-ecommerce - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. sya/yii2-ecommerce

ActiveYii2-extension[Framework](/categories/framework)

sya/yii2-ecommerce
==================

Module manager ecommerce, add product to cart

1.0(9y ago)6852MITPHPPHP &gt;=5.4.0

Since Feb 23Pushed 8y ago2 watchersCompare

[ Source](https://github.com/sya0710/yii2-ecommerce)[ Packagist](https://packagist.org/packages/sya/yii2-ecommerce)[ RSS](/packages/sya-yii2-ecommerce/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

yii2-ecommerce
==============

[](#yii2-ecommerce)

Module manager ecommerce, CRUD ecommerce

Installation
------------

[](#installation)

Add

```
"sya/yii2-ecommerce": "dev-master"
```

to the require section of your composer.json file.

Module
======

[](#module)

```
use sya\gallery\Module;
'modules' => [
    'ecommerce' => [
        'class' => 'sya\ecommerce\Module',
        'itemModule' => 'sya\ecommerce\models\Order',
        'customerTable' => [
            'customerModule' => 'app\modules\account\models\User',
            'customerColumns' => [
                [
                    'attribute' => 'p_fullname',
                    'hAlign'=>'center',
                    'vAlign'=>'middle',
                    'contentOptions' => [
                        'class' => 'customer_p_fullname'
                    ],
                ],
                [
                    'attribute' => 'p_address',
                    'hAlign'=>'center',
                    'vAlign'=>'middle',
                    'contentOptions' => [
                        'class' => 'customer_p_address'
                    ],
                ],
            ],
            'customerSearch' => 'searchCustomer',
            'fieldOrder' => [
                'full_name' => 'p_fullname',
                'address' => 'p_address',
            ]
        ],
        'productTable' => [
            'productModule' => 'app\modules\product\models\Product',
            'productColumns' => [
                [
                    'attribute' => 'sku',
                    'hAlign'=>'center',
                    'vAlign'=>'middle',
                ],
                [
                    'attribute' => 'title',
                    'hAlign'=>'center',
                    'vAlign'=>'middle',
                ],
                [
                    'attribute' => 'price',
                    'hAlign'=>'center',
                    'vAlign'=>'middle',
                    'format'=>['decimal', 0],
                ],
                [
                    'class'=>'kartik\grid\BooleanColumn',
                    'attribute'=>'status',
                    'vAlign'=>'middle',
                    'format'=>'raw',
                    'trueLabel' => 'Hiện',
                    'falseLabel' => 'Ẩn'
                ]
            ],
            'fieldOrder' => [
                'title' => 'title',
                'sku' => 'sku',
                'price' => 'price',
            ]
        ]
    ],
]
```

\#Allow chose add one product or multiple product

```
'multiple' => false,
```

\#Enable generate activation code

```
'enableActivitionCode' => true,
```

Demo
----

[](#demo)

Controller

```
use sya\ecommerce\Ecommerce;

public function actionIndex(){
    $queryParams = Yii::$app->request->getQueryParams();
    $ecommerce = Ecommerce::module();
    $searchModel = new $ecommerce->itemModule;
    $searchModel->scenario = 'search';
    $dataProvider = $searchModel->search($queryParams);

    // Set title page
    Yii::$app->view->title = Yii::t($this->module->id, 'Order');
    Yii::$app->view->params['breadcrumbs'][] = Yii::$app->view->title;

    return $this->render('index', [
        'searchModel' => $searchModel,
        'dataProvider' => $dataProvider
    ]);
}
```

View

```
use sya\ecommerce\Ecommerce;
use sya\ecommerce\Module;
use yii\helpers\Url;

echo Ecommerce::widget([
    'statisticColumns' => [
        [
            'header' => 'New Orders',
        ],
        [
            'header' => 'Orders Pending',
        ],
        [
            'header' => 'Orders',
            'timeOptions' => [
                'class' => 'label-info'
            ],
            'totalStatistic' => '275,800'
        ],
        [
            'header' => 'Income',
            'smallHeader' => 'In first month',
            'time' => 'Low value',
            'timeOptions' => [
                'class' => 'label-danger'
            ]
        ],
    ],
    // Item and gridview setting
    'itemSettings' => [
        'dataProvider' => $dataProvider,
        'searchModel' => $searchModel,
        'actions' => [
            Module::ACTION_CREATE => Url::to(['/order/backend/default/create']),
            Module::ACTION_INDEX => Url::to(['/order/backend/default/index']),
            Module::ACTION_UPDATE => Url::to(['/order/backend/default/update']),
            Module::ACTION_DELETE => Url::to(['/order/backend/default/delete']),
        ],
    ],
]);
```

Component
=========

[](#component)

```
'cart' => [
    'class' => 'sya\ecommerce\components\Component'
],
```

Use component
=============

[](#use-component)

```
// Add item product to cart
$product_info = [
    '57ce373574530' => [
        'id' => '57ce373574530',
        'title' => '213213123213',
        'price' => '25000',
        'old_price' => '0',
        'quantity' => 3
    ],
    '581957637371d' => [
        'id' => '581957637371d',
        'title' => 'rrrrrr123',
        'price' => '200000',
        'old_price' => '0',
        'quantity' => 5
    ],
];

Yii::$app->cart->addCart($product_info);

// Create order
$customer_info = [
    'fullname' => 'Minion',
    'phone' => '0123456789',
    'note_customer' => 'Done'
];
Yii::$app->cart->createOrder($product_info, $customer_info);

// Get id cart
Yii::$app->cart->getCartId();

// Get infomation of cart
Yii::$app->cart->getCart();

// Update quantity of product
$product_qty = [
    '581957637371d' => 3,
    '57ce373574530' => 4,
];
Yii::$app->cart->updateQty($product_qty);
```

I18n
----

[](#i18n)

```
'components' => [
    'i18n' => [
        'translations' => [
            'ecommerce' => ['class' => 'yii\i18n\PhpMessageSource', 'basePath' => '@syaEcommerce/messages'],
        ],
    ],
],

```

License
-------

[](#license)

**yii2-ecommerce** is released under the MIT License. See the bundled LICENSE.md for details.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 79.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3365d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7b91c5c73679d5c0f16e9e5e3c4c2cc12617f19b46118a3214331e0cce306fcb?d=identicon)[sya0710](/maintainers/sya0710)

---

Top Contributors

[![phongnv093](https://avatars.githubusercontent.com/u/6872425?v=4)](https://github.com/phongnv093 "phongnv093 (34 commits)")[![sya0710](https://avatars.githubusercontent.com/u/11871538?v=4)](https://github.com/sya0710 "sya0710 (9 commits)")

---

Tags

yii2extensionecommerce

### Embed Badge

![Health badge](/badges/sya-yii2-ecommerce/health.svg)

```
[![Health](https://phpackages.com/badges/sya-yii2-ecommerce/health.svg)](https://phpackages.com/packages/sya-yii2-ecommerce)
```

###  Alternatives

[skeeks/cms

SkeekS CMS — control panel and tools based on php framework Yii2

13825.6k47](/packages/skeeks-cms)[marekpetras/yii2-ajax-box-widget

Ajax Box widget for Yii 2 Framework.

1814.6k](/packages/marekpetras-yii2-ajax-box-widget)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
