PHP code example of eluhr / yii2-shop-module
1. Go to this page and download the library: Download eluhr/yii2-shop-module library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
eluhr / yii2-shop-module example snippets
use kartik\grid\Module as GridViewModule;
use eluhr\shop\Module as ShopModule;
use eluhr\shop\components\Payment;
use eluhr\shop\components\providers\DirectDebitPayment;
use eluhr\shop\components\providers\PayPalPayment;
use eluhr\shop\components\providers\PayrexxPayment;
use eluhr\shop\components\providers\SaferPayPayment;
use eluhr\shop\models\Order;
use eluhr\shop\components\ShoppingCart;
return [
'aliases' => [
'eluhr/shop' => '@vendor/eluhr/yii2-shop-module/src'
],
'modules' => [
'shop' => [
'class' => ShopModule::class,
],
'gridview' => [
'class' => GridViewModule::class
]
],
'components' => [
'shoppingCart' => [
'class' => ShoppingCart::class
],
'payment' => [
'class' => Payment::class,
'currency' => 'EUR',
'providers' => [
Order::TYPE_PREPAYMENT => [
'class' => DirectDebitPayment::class
],
Order::TYPE_PAYREXX => [
'class' => PayrexxPayment::class,
'apiKey' => getenv('PAYREXX_API_KEY'),
'instanceName' => getenv('PAYREXX_INSTANCE_NAME'),
'apiBaseDomain' => getenv('PAYREXX_API_BASE_DOMAIN')
],
Order::TYPE_PAYPAL => [
'class' => PayPalPayment::class,
'mode' => getenv('PAYPAL_MODE'),
'clientId' => getenv('PAYPAL_CLIENT_ID'),
'clientSecret' => getenv('PAYPAL_CLIENT_SECRET')
],
Order::TYPE_SAFERPAY => [
'class' => SaferPayPayment::class,
'baseUrl' => getenv('SAFERPAY_BASE_URL'),
'customerId' => getenv('SAFERPAY_CUSTOMER_ID'),
'terminalId' => getenv('SAFERPAY_TERMINAL_ID'),
'username' => getenv('SAFERPAY_USERNAME'),
'password' => getenv('SAFERPAY_PASSWORD')
]
]
],
'urlManager' => [
'rules' => [
'shop' => 'shop/default/index',
'warenkorb/uebersicht' => 'shop/shopping-cart/overview',
'warenkorb/checkout' => 'shop/shopping-cart/checkout',
'warenkorb/meine-bestellung/<orderId>' => 'shop/shopping-cart/prepayment',
'shop/meine-bestellungen' => 'shop/orders/all',
'shop/meine-bestellungen/<orderId>' => 'shop/orders/detail',
'shop/<productTitle>-<productId:\d+>/<variantTitle>-<variantId:\d+>' => 'shop/product/detail',
'shop/<productTitle>-<productId:\d+>' => 'shop/product/detail'
],
'ignoreLanguageUrlPatterns' => [
'#^shop/shopping-cart/check-discount-code#' => '#^shop/shopping-cart/check-discount-code#',
'#^shop/dashboard/update-shipping-link#' => '#^shop/dashboard/update-shipping-link#',
'#^shop/data/add-tag-to-filter#' => '#^shop/data/add-tag-to-filter#',
'#^shop/data/add-tag-to-product#' => '#^shop/data/add-tag-to-product#',
'#^shop/data/sort-filter-tags#' => '#^shop/data/sort-filter-tags#',
'#^shop/data/sort-products#' => '#^shop/data/sort-products#',
'#^shop/data/sort-filters#' => '#^shop/data/sort-filters#',
'#^shop/data/sort-variants#' => '#^shop/data/sort-variants#',
'#^shop/data/update-email-template#' => '#^shop/data/update-email-template#',
'#^shop/data/update-email-template-context-menu#' => '#^shop/data/update-email-template-context-menu#',
'#^shop/data/load-template#' => '#^shop/data/load-template#',
]
]
],
'controllerMap' => [
'migrate' => [
'migrationPath' => [
'@vendor/eluhr/yii2-shop-module/src/migrations'
]
]
]
];
'modules' => [
'shop' => [
'class' => ShopModule::class,
# .... other shop configs
'frontendAccessRules' => [
[
'allow' => true,
'roles' => ['@'],
],
],
],
],
bash
docker-compose run --rm php yii shop:crud --appconfig=/app/vendor/eluhr/yii2-shop-module/src/config/giiant.php