στο αρχείο /catalog/view/theme/[themename]/template/common/header.tpl πριν το κλείσιμο του </head> προσθήκη ο παρακάτω κώδικας με αλλαγή των κωδικό SA-000000 με του πελάτη
1 2 3 4 5 6 7 8 9 10 |
<script> (function(a,b,c,d,e,f,g){a['SkroutzAnalyticsObject']=e;a[e]= a[e] || function(){ (a[e].q = a[e].q || []).push(arguments);};f=b.createElement(c);f.async=true; f.src=d;g=b.getElementsByTagName(c)[0];g.parentNode.insertBefore(f,g); })(window,document,'script','https://analytics.skroutz.gr/analytics.min.js','skroutz_analytics'); skroutz_analytics('session', 'connect', 'SA-00000000'); </script> |
στο αρχείο /catalog/controller/checkout/success.php στην γραμμή 10 προσθήκη ο παρακάτω κώδικας
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
/* skroutz start */ $order_totals = $this->model_checkout_order->getOrderTotals($this->session->data['order_id']); $order_products = $this->model_checkout_order->getOrderProducts($this->session->data['order_id']); if(isset($order_totals)){ $tax=0; $ship=0; $revenue=0; $data['skroutz_order_data']['order_id'] = $this->session->data['order_id']; foreach ($order_totals as $order_total) { if($order_total['code'] == 'sub_total'){ $revenue = round($order_total['value'],2); } if($order_total['code'] == 'shipping'){ $ship = round($order_total['value'], 2); } if($order_total['code'] == 'tax'){ $tax= round($order_total['value'],2); } } $data['skroutz_order_data']['revenue'] = $revenue + $tax + $ship; $ship = round($ship * 1.24, 2); $data['skroutz_order_data']['shipping'] = $ship; $data['skroutz_order_data']['tax'] = $tax; foreach ($order_products as $product) { $data['skroutz_order_data']['products'][] = array( 'product_id' => $product['product_id'], 'name' => addslashes($product['name']), 'quantity' => $product['quantity'], 'price' => $product['price'], 'tax' => $product['tax'] ); } } /* skroutz end */ |
στο αρχείο /catalog/view/theme/[themename]/template/common/success.tpl στην γραμμή 10 προσθήκη ο παρακάτω κώδικας
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<?php if( isset($skroutz_order_data) ) { ?> <script> skroutz_analytics('ecommerce', 'addOrder', { order_id: '<?php echo $skroutz_order_data['order_id']; ?>', revenue: '<?php echo $skroutz_order_data['revenue']; ?>', shipping: '<?php echo $skroutz_order_data['shipping']; ?>', tax: '<?php echo $skroutz_order_data['tax']; ?>' }); <?php foreach($skroutz_order_data['products'] as $skroutz_product ) { ?> skroutz_analytics('ecommerce', 'addItem', { order_id: '<?php echo $skroutz_order_data['order_id']; ?>', product_id: '<?php echo $skroutz_product['product_id']; ?>', name: '<?php echo $skroutz_product['name']; ?>', price: '<?php echo round($skroutz_product['price']+$skroutz_product['tax'],2); ?>', quantity: '<?php echo $skroutz_product['quantity']; ?>' }); <?php } ?> </script> <?php } ?> |