From 8467c8d3f77c35043d5a346ca00c390b6e64d7c9 Mon Sep 17 00:00:00 2001 From: yarik Date: Tue, 28 Mar 2017 17:25:29 +0300 Subject: [PATCH] Google ecommerce --- common/models/Orders.php | 7 ++++++- common/models/OrdersProducts.php | 83 ++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------- frontend/views/order/success.php | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------- 3 files changed, 108 insertions(+), 83 deletions(-) diff --git a/common/models/Orders.php b/common/models/Orders.php index 5685b4c..61eb360 100755 --- a/common/models/Orders.php +++ b/common/models/Orders.php @@ -4,7 +4,12 @@ use Yii; use yii\web\Session; use common\modules\product\models\ProductVariant; - + + /** + * Class Orders + * + * @property OrdersProducts[] $products + */ class Orders extends \yii\db\ActiveRecord { diff --git a/common/models/OrdersProducts.php b/common/models/OrdersProducts.php index dbc7b3e..a7f8eb7 100755 --- a/common/models/OrdersProducts.php +++ b/common/models/OrdersProducts.php @@ -1,40 +1,53 @@ 'Продукт', - 'name'=>'Вид', - 'art'=>'Артикул', - 'cost'=>'Цена за один', - 'count'=>'Кол.', - 'sum_cost'=>'Сумма', - ]; - } - - public function getProductVariant() + class OrdersProducts extends \yii\db\ActiveRecord { - return $this->hasOne(ProductVariant::className(), ['product_variant_id' => 'mod_id']); - } -} \ No newline at end of file + public static function tableName() + { + return 'orders_products'; + } + + public function rules() + { + return [ + [ + [ 'order_id' ], + 'required', + ], + //['email', 'email'], + [ + [ + 'product_name', + 'name', + 'price', + 'count', + 'sum_cost', + 'mod_id', + 'sku', + ], + 'safe', + ], + ]; + } + + public function attributeLabels() + { + return [ + 'product_name' => 'Продукт', + 'name' => 'Вид', + 'art' => 'Артикул', + 'cost' => 'Цена за один', + 'count' => 'Кол.', + 'sum_cost' => 'Сумма', + ]; + } + + public function getProductVariant() + { + return $this->hasOne(ProductVariant::className(), [ 'product_variant_id' => 'mod_id' ]); + } + } \ No newline at end of file diff --git a/frontend/views/order/success.php b/frontend/views/order/success.php index 79eb7d8..be364a1 100755 --- a/frontend/views/order/success.php +++ b/frontend/views/order/success.php @@ -9,19 +9,19 @@ \Yii::$app->session->remove('order_data'); $order = $order_data[ 'order' ]; $variants = $order_data[ 'variants' ]; - - $this->params['remarketing']['type'] = 'conversion'; + + $this->params[ 'remarketing' ][ 'type' ] = 'conversion'; if (count($variants) > 1) { foreach ($variants as $variant) { - $this->params['remarketing']['id'][] = $variant['mod_id']; - $this->params['remarketing']['price'][] = $variant['price']; + $this->params[ 'remarketing' ][ 'id' ][] = $variant[ 'mod_id' ]; + $this->params[ 'remarketing' ][ 'price' ][] = $variant[ 'price' ]; } - } elseif(!empty($variants) && isset($variants[0])) { - $this->params['remarketing']['id'] = $variants[0]['mod_id']; - $this->params['remarketing']['price'] = $variants[0]['price']; + } elseif (!empty( $variants ) && isset( $variants[ 0 ] )) { + $this->params[ 'remarketing' ][ 'id' ] = $variants[ 0 ][ 'mod_id' ]; + $this->params[ 'remarketing' ][ 'price' ] = $variants[ 0 ][ 'price' ]; } else { - $this->params['remarketing']['id'] = ''; - $this->params['remarketing']['price'] = ''; + $this->params[ 'remarketing' ][ 'id' ] = ''; + $this->params[ 'remarketing' ][ 'price' ] = ''; } ?> @@ -33,45 +33,52 @@
- - - - - - + ?> + ga( + 'ecommerce:addTransaction', { + 'id': 'id; ?>', + 'affiliation': 'www.linija-svitla.ua', + 'revenue': '', + } + ); + ga('ecommerce:send'); + + +
- Заказ успешно осуществлён! Во время обработки вашего заказа менеджер свяжется с Вами. -

-
- Уникальный номер заказа: id; ?> -
-

-
- Спасибо за заказ!!

- « На главную -
- - -

-- libgit2 0.21.4