Welcome to the Kelkoo Group Customer Service

PrestaShop 1.7 integration of Kelkoo Sales Tracking

Information for those merchants who use Prestashop 1.7

 

Implement the code

Go to the directory /controllers/front/ and open the file OrderConfirmationController.php.

Search the following line:

 

public function initContent()

            {

and add this text:

                /* Kelkoo Sales Tracking */

                $order = new Order($this->id_order);

                $products = $order->getProducts();

                $productsKelkoo=array();

                foreach ($products as $product) {

                        $productKelkoo=array('productname'=>$product['product_name'],

                                             'productid'=>$product['product_reference'],

                                             'quantity'=>$product['product_quantity'],

                                             'price'=>$product['unit_price_tax_incl']);

                        array_push($productsKelkoo,$productKelkoo);

                }

                $this->context->smarty->assign(array(

                        'products_json' => json_encode($productsKelkoo),

                        'sales' => $order->getOrdersTotalPaid(),

                        'orderid' => $this->id_order

                ));

                /* end Kelkoo Sales Tracking*/

 

Then go to the directory /themes/xxxx/templates/checkout/_partials/ (where xxxx is the name of the theme you chose, the default is “classic”), open the file order-confirmation-table.tpl and add Kelkoo Sales Tracking at the bottom of the file

 

            <script type="text/javascript">

             var products_json_escaped="{$products_json}".replace(/&quot;/g, '"');

             var _kkstrack = {

                  merchantInfo: [{ country:"COUNTRY", merchantId:"COM_ID" }],

                  orderValue: '{$sales}',

                  orderId: '{$orderid}',

                  basket: products_json_escaped

                };

                (function() {

                  var s = document.createElement('script');

                  s.type = 'text/javascript';

                  s.async = true;

                  s.src = 'https://s.kk-resources.com/ks.js';

                  var x = document.getElementsByTagName('script')[0];

                  x.parentNode.insertBefore(s, x);

                })();

             </script>

 

Have a look to the end of this guide for the Green Values.

If you use PayPal module for payments

If you enabled PayPal payment then you have to change two more files: paypal.php and order_confirmation.tpl

The first file paypal.php is located into /modules/paypal/

Put following code just before the return instruction of static function hookDisplayOrderConfirmation:

 

                /* Kelkoo Sales Tracking */

                $products = $params['order']->getProducts();

                $productsKelkoo=array();

                foreach ($products as $product) {

                        $productKelkoo=array('productname'=>$product['product_name'],

                                             'productid'=>$product['product_reference'],

                                             'quantity'=>$product['product_quantity'],

                                             'price'=>$product['unit_price_tax_incl']);

                        array_push($productsKelkoo,$productKelkoo);

                }

                $this->context->smarty->assign(array(

                        'products_json' => json_encode($productsKelkoo),

                        'sales' => $paypal_order->total_paid,

                        'orderid' => $paypal_order->id_order

                ));

                /* end Kelkoo Sales Tracking*/

 

The second file order-confirmation.tpl is located into /views/templates/hook/

Add Kelkoo Sales Tracking at the bottom of the file:

 

            <script type="text/javascript">

             var products_json_escaped="{$products_json}".replace(/&quot;/g, '"');

             var _kkstrack = {

                  merchantInfo: [{ country:"COUNTRY", merchantId:"COM_ID" }],

                  orderValue: '{$sales}',

                  orderId: '{$orderid}',

                  basket: products_json_escaped

                };

                (function() {

                  var s = document.createElement('script');

                  s.type = 'text/javascript';

                  s.async = true;

                  s.src = 'https://s.kk-resources.com/ks.js';

                  var x = document.getElementsByTagName('script')[0];

                  x.parentNode.insertBefore(s, x);

                })();

             </script>

 

 

As you can see, Kelkoo Sales Tracking requires a few details of the order; for Prestashop’s users everything has already been set, the only thing to change are the green values.

  • GREEN VALUES are fixed (static) values to pass along in the tag;
  • COM_ID: This is the unique ID representing your shop within the Kelkoo system. Note that you can log into your Merchant Extranet account and directly use the JS tag generator that will automatically update the code with your COMID. You then just need to copy-paste the code generated and update the other values below.
  • COUNTRY is the 2-letter country code for the country on which your products are listed on Kelkoo: ‘at’ for Austria, ‘be’ for Belgium, ‘br’ for Brazil, ‘ch’ for Switzerland, ‘cz’ for Czech Republic, ‘de’ for Germany, ‘dk’ for Denmark, ‘es’ for Spain, ‘fi’ for Finland, ‘fr’ for France, ‘ie’ for Ireland, ‘it’ for Italy, ‘mx’ for Mexico, ‘nb’ for Flemish Belgium, ‘nl’ for Netherlands, ‘no’ for Norway, ‘pl’ for Poland, ‘pt’ for Portugal, ‘ru’ for Russia, ‘se’ for Sweden, ‘uk’ for United Kingdom, ‘us’ for United States.