andrewdanilov / yii2-shop
Yii2 Shop
Fund package maintenance!
Patreon
Installs: 98
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
pkg:composer/andrewdanilov/yii2-shop
Requires
- php: >=5.6.0
- ext-json: *
- 2amigos/yii2-date-picker-widget: ~1.0
- andrewdanilov/yii2-behaviors: ~1.0.25
- andrewdanilov/yii2-ckeditor: ~1.0.1
- andrewdanilov/yii2-fancybox: ~1.0.0
- andrewdanilov/yii2-grid-tools: ~1.0.2
- andrewdanilov/yii2-helpers: ~1.0.16
- andrewdanilov/yii2-input-images: ~1.0.2
- kartik-v/yii2-widget-select2: @dev
- yiisoft/yii2: ~2.0.0
- yiisoft/yii2-bootstrap: ^2.0
- dev-main
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.43
- 1.0.42
- 1.0.41
- 1.0.40
- 1.0.39
- 1.0.38
- 1.0.37
- 1.0.36
- 1.0.35
- 1.0.34
- 1.0.33
- 1.0.32
- 1.0.31
- 1.0.30
- 1.0.29
- 1.0.28
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2025-09-25 19:09:28 UTC
README
Customizable shop module with hierarchical categories, product properties and options, cart, product stickers. Supports i18n.
Installation
The preferred way to install this extension is through composer.
Either run
composer require andrewdanilov/yii2-shop "~1.1.0"
or add
"andrewdanilov/yii2-shop": "~1.1.0"
to the require section of your composer.json file.
Then run db migrations, to create needed tables:
php yii migrate --migrationPath=@andrewdanilov/shop/console/migrations
Do not forget to run migrations after extension updates too.
Usage
In backend main config modules section add:
$config = [ // ... 'modules' => [ // ... 'shop' => [ 'class' => 'andrewdanilov\shop\backend\Module', // access role for module controllers, optional, default is ['@'] 'access' => ['admin'], // path to user translates, optional, default is '@andrewdanilov/shop/common/messages' 'translatesPath' => '@common/messages/shop', // file manager configuration, optional, default is: 'fileManager' => [ 'basePath' => '@frontend/web', 'paths' => [ [ 'name' => 'Product images', 'path' => 'upload/images/product', ], [ 'name' => 'Category images', 'path' => 'upload/images/category', ], [ 'name' => 'Brand images', 'path' => 'upload/images/brand', ], [ 'name' => 'Sticker images', 'path' => 'upload/images/sticker', ], [ 'name' => 'Documents', 'path' => 'upload/images/docs', ], ], ], ], ], ];
Here access option allows restricting access to defined roles.
In frontend main config modules section and bootstrap section add shop module:
$config = [ // ... 'modules' => [ // ... 'shop' => [ 'class' => 'andrewdanilov\shop\frontend\Module', // path to template views, optional, default is '@andrewdanilov/shop/frontend/views' 'templatesPath' => '@frontend/views/shop', // path to mail template views, optional, default is '@andrewdanilov/shop/common/mail' 'mailTemplatesPath' => '@common/mail/shop', // path to user translates, optional, default is '@andrewdanilov/shop/common/messages' 'translatesPath' => '@common/messages/shop', // main currency, using by shop, optional, default is 'USD' 'currency' => '$', ], ], // If you use own templates paths, you need to add `shop` module to `bootstrap` section // to enable i18n and other settings before using module parts. // This is optional, but recommended in any way. 'bootstrap' => [ // ... 'shop', ], ];
In common/config/params.php config file add/modify adminEmail, senderEmail and senderName params like this
return [ // ... 'adminEmail' => ['admin@example.com', 'admin2@example.com'], 'senderEmail' => 'noreply@example.com', 'senderName' => 'Robot', // ... ];
You will get system messages (i.e., order from site) on one of adminEmail e-mails from senderEmail e-mail.
To transport e-mail messages you must correctly set up mailer component in common/config/main-local.php.
For example SMTP transport:
return [ 'components' => [ // ... 'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'useFileTransport' => false, 'transport' => [ 'class' => 'Swift_SmtpTransport', 'username' => 'sender@example.com', 'password' => 'example_password', 'host' => 'smtp.example.com', 'port' => '465', 'encryption' => 'ssl', ], ], ], ];
Backend menu items:
$shop_menu_items = [ ['label' => 'Orders', 'url' => ['/shop/order'], 'icon' => 'shopping-cart'], ['label' => 'Products', 'url' => ['/shop/product'], 'icon' => 'shopping-bag'], ['label' => 'Brands', 'url' => ['/shop/brand'], 'icon' => 'leaf'], ['label' => 'Options', 'url' => ['/shop/option'], 'icon' => 'check-square'], ['label' => 'Properties', 'url' => ['/shop/property'], 'icon' => 'list'], ['label' => 'Property groups', 'url' => ['/shop/group'], 'icon' => 'tags'], ['label' => 'Linking', 'url' => ['/shop/relation'], 'icon' => 'share-alt'], ['label' => 'Pay methods', 'url' => ['/shop/pay'], 'icon' => 'credit-card'], ['label' => 'Shipping methods', 'url' => ['/shop/delivery'], 'icon' => 'truck'], ['label' => 'Stickers', 'url' => ['/shop/sticker'], 'icon' => 'bookmark'], ]; echo \yii\widgets\Menu::widget(['items' => $shop_menu_items]);
Widgets
You can use these widgets to add cart, mini-cart, modal windows and buy buttons to your shop:
// Place this widget everywhere you want to see buy button echo \andrewdanilov\shop\frontend\widgets\Buttons\Buy::widget([ 'product_id' => 123, // optional, text label displaying on buy button 'label' => 'Buy it!', // optional, html tag uset for representing buy button 'tag' => 'div', // optional, extended classes for buy button 'classes' => 'orange-buy-button', // optional, use to define own template for buy button 'template' => '@frontend/views/shop/buy-button', ]); // Place these two widgets on checkout page. // First is for displaying form to retrieve client information like e-mail, phone, etc. // Second is for displaying cart contents table. \andrewdanilov\shop\frontend\widgets\Checkout\Client::widget(); \andrewdanilov\shop\frontend\widgets\Checkout\FullCart::widget(); // Widget for mini-cart button. Place it somewhere in main layout. \andrewdanilov\shop\frontend\widgets\Checkout\MiniCart::widget(); // Widget for placing modal windows on page \andrewdanilov\shop\frontend\widgets\Forms\Modals::widget();
If you need your own content inside the widgets, you can copy the widget directory to your desired location and then call them from there. If you do, remember to change the namespaces accordingly.
Features
I18n
Extension supports internationalisation. You can set your language in common/config/main.php
return [ // ... 'language' => 'ru-RU', // ... ];
On the moment you can use one of languages out of the box: English, Russian. Also, you can create and use your own
translations by defining translatesPath property of shop module (see above). Therefore, you need to place
language files to xx-XX folder inside translatesPath path. You can copy example from src/common/messages path
of extension.