2017 © Pedro Peláez
 

yii2-extension blcms-cart

Cart component for Blcms-shop module

image

black-lamp/blcms-cart

Cart component for Blcms-shop module

  • Thursday, May 17, 2018
  • by GutsVadim
  • Repository
  • 6 Watchers
  • 0 Stars
  • 415 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 33 Versions
  • 0 % Grown

The README.md

Blcms-cart

Cart module and component for Blcms-shop module, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist black-lamp/blcms-cart "*"

or add to the require section of your composer.json file:, (*4)

"black-lamp/blcms-cart": "*"

If you need to save orders to database, apply next migration:, (*5)

Migrations - php yii migrate --migrationPath=@vendor/black-lamp/blcms-staticpage/migrations - php yii migrate --migrationPath=@vendor/black-lamp/blcms-cart/migrations, (*6)

Common configuration, (*7)

'name' => 'ProjectName',
'components' => [
    'cart' => [
                'class' => bl\cms\cart\CartComponent::className(),
                'emailNotifications' => true,
                'sender' => 'info@mail.com',
                'sendTo' => [
                    'test@mail.com'
                ],
                'saveToDataBase' => true,

                'enablePayment' => true, //If true, you need to add blcms-payment module to your composer.json file.
            ],
],

Frontend configuration, (*8)

'modules' => [
    'cart' => [
                'class' => bl\cms\cart\frontend\Module::className(),
            ],
    'user' => [
                'class' => 'dektrium\user\Module',
                'modelMap' => [
                    'User' => 'bl\cms\shop\common\components\user\models\User',
                    'Profile' => 'bl\cms\cart\common\components\user\models\Profile',
                ],
                'controllerMap' => [
                    'registration' => 'bl\cms\cart\common\components\user\controllers\RegistrationController',
                    'settings' => 'bl\cms\cart\frontend\components\user\controllers\SettingsController',
                ],
                'as frontend' => 'dektrium\user\filters\FrontendFilter',
            ],
'components' => [
    //For Dektrium User module
    'mailer' => [
                'class' => yii\swiftmailer\Mailer::className(),
                'useFileTransport' => false,
                'messageConfig' => [
                    'charset' => 'UTF-8',
                ],
                'transport' => [
                    'class' => 'Swift_SmtpTransport',
                    'username' => 'info@mail.com',
                    'password' => '123456789',
                    'host' => 'mail.server.com',
                    'port' => '587',
                ],
            ],
    //For cart
   'shopMailer' => [
        'class' => yii\swiftmailer\Mailer::className(),
        'useFileTransport' => false,
        'messageConfig' => [
            'charset' => 'UTF-8',
        ],
        'viewPath' => '@vendor/black-lamp/blcms-cart/frontend/views/mail',
        'htmlLayout' => '@vendor/black-lamp/blcms-cart/frontend/views/mail/layout',
        'transport' => [
                'class' => 'Swift_SmtpTransport',
                'username' => 'info@host.ua',
                'password' => 'password',
                'host' => 'pop.host.ua',
                'port' => '587',
            ],
    ],
]

Backend configuration, (*9)

'modules' => [
        'cart' => [
            'class' => bl\cms\cart\backend\Module::className(),
        ],
        'user' => [
                    'class' => 'dektrium\user\Module',
                    'enableRegistration' => false,
                    'enableConfirmation' => false,
                    'admins' => ['admin'],
                    'adminPermission' => 'rbacManager',
                    'modelMap' => [
                        'Profile' => 'bl\cms\cart\common\components\user\models\Profile',
                    ],
                    'as backend' => [
                        'class' => 'dektrium\user\filters\BackendFilter',
                        'only' => ['register'], // Block View Register Backend
                    ],
                ],

        'seo' => [
            'class' => 'bl\cms\seo\backend\Module'
        ],
    ],

Params 'adminEmail' => 'info@mail.ua',, (*10)

Usage

Adding to cart, (*11)

Yii::$app->cart->add($productId, $count, $priceId);

Getting total cost, (*12)

$totalCost = Yii::$app->cart->getTotalCost();

Getting all user orders ''' $orders = Yii::$app->cart->getAllUserOrders(); ''', (*13)

Clearing cart, (*14)

Yii::$app->cart->clearCart();

Static page, (*15)

There is page in Static page module for cart show page on frontend. It has key 'cart'. You need to configure it: add title, seo-data etc. http://YOUR_DOMAIN.com/admin/seo/static, (*16)

Logging This configuration is for Shop module and Cart module., (*17)

For enable logging add log component to your common configuration file:, (*18)

'components' => [
        'log' => [
            'targets' => [
                [
                    'logTable' => 'shop_log',
                    'class' => 'yii\log\DbTarget',
                    'levels' => ['info'],
                    'logVars' => [],
                    'categories' => [
                        'afterCreateProduct', 'afterDeleteProduct', 'afterEditProduct',
                        'afterCreateCategory', 'afterEditCategory', 'afterDeleteCategory',
                    ],
                ],
                [
                    'logTable' => 'cart_log',
                    'class' => 'yii\log\DbTarget',
                    'levels' => ['info'],
                    'logVars' => [],
                    'categories' => [
                        'afterChangeOrderStatus'
                    ],
                ],
                [
                    'logTable' => 'user_log',
                    'class' => 'yii\log\DbTarget',
                    'logVars' => [],
                    'levels' => ['info'],
                    'categories' => [
                        'afterRegister', 'afterConfirm'
                    ],
                ],
            ],
        ],

Then apply migration, but only after you will configure your app. The migration will create tables for log targets, which are listed in configuration., (*19)

php yii migrate --migrationPath=@yii/log/migrations/

In backend configuration of your module add, (*20)

'enableLog' => true,

Email templates

Configure frontend component:, (*21)

components => [
    'emailTemplates' => [
        'class' => bl\emailTemplates\components\TemplateManager::class
    ],
]

After you will apply migrations, there will be able two records for emails - 'new-order' and 'order-success'. You can find its in admin panel: /admin/email-templates/default/list In mail subject and object you can use next variables: {name}, {surname}, {patronymic}, {email}, {phone}, {orderUid}, {zip}, {country}, {region}, {city}, {street}, {house}, {apartment}, {products}, {totalCost}. Variable {products} renders view @bl\cms\cart\frontend\views\mail\products You can setup mail layout in frontend config for shopMailer component. Now it use @bl\cms\cart\frontend\views\mail\layout, (*22)

Welcome email You can create templates here: /admin/email-templates/default/list (use 'welcome' key for it) Use next variables: {token} => confirmation token, (*23)

Recovery email Create 'recovery' template. Use next variables: {token} => confirmation token, (*24)

The Versions

17/05 2018

dev-master

9999999-dev

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

by Albert Gainutdinov

yii2 shop cart blcms

17/03 2017
15/03 2017
06/03 2017
06/02 2017
11/01 2017

v0.1.3

0.1.3.0

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

by Albert Gainutdinov

yii2 shop cart blcms

27/12 2016

v0.1.2

0.1.2.0

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

by Albert Gainutdinov

yii2 shop cart blcms

20/12 2016

v0.1.1

0.1.1.0

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

by Albert Gainutdinov

yii2 shop cart blcms

05/12 2016

v0.1.0

0.1.0.0

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

by Albert Gainutdinov

yii2 shop cart blcms

23/11 2016

v0.0.5

0.0.5.0

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

by Albert Gainutdinov

yii2 shop cart blcms

23/11 2016

v0.0.4

0.0.4.0

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

by Albert Gainutdinov

yii2 shop cart blcms

31/10 2016

v0.0.3

0.0.3.0

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

31/10 2016

v0.0.2

0.0.2.0

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

28/10 2016

0.0.1.3

0.0.1.3

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

27/10 2016

v0.0.1.2

0.0.1.2

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

22/10 2016

0.0.1.1

0.0.1.1

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

21/10 2016

0.0.1.0

0.0.1.0

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

21/10 2016

0.0.0.15

0.0.0.15

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

21/10 2016

0.0.0.16

0.0.0.16

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

21/10 2016

0.0.0.14

0.0.0.14

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

20/10 2016

0.0.0.13

0.0.0.13

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

19/10 2016

0.0.0.12

0.0.0.12

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

13/10 2016

0.0.0.10

0.0.0.10

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

13/10 2016

0.0.0.11

0.0.0.11

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

10/10 2016

0.0.0.9

0.0.0.9

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

05/10 2016

0.0.0.7

0.0.0.7

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

05/10 2016

0.0.0.8

0.0.0.8

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

03/10 2016

0.0.0.6

0.0.0.6

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

03/10 2016

0.0.0.5

0.0.0.5

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

29/09 2016

0.0.0.3

0.0.0.3

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

29/09 2016

0.0.0.4

0.0.0.4

Cart component for Blcms-shop module

  Sources   Download

GPL-3.0

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

26/09 2016

0.0.0.1

0.0.0.1

Cart component for Blcms-shop module

  Sources   Download

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms

26/09 2016

0.0.0.2

0.0.0.2

Cart component for Blcms-shop module

  Sources   Download

The Requires

 

by Albert Gainutdinov

yii2 shop cart blcms