Welcome to the Kelkoo Group Customer Service

PrestaShop integration of Kelkoo Sales Tracking

Information for those merchants who use Prestashop.
Important! Before doing any changes, please remember to back up files you’re going to modify.
Additionally, you need to be sure that in the control panel, Advanced settings -> Performance, the option “Ricompile files of template if updated” is flagged.


 

Step 1: 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(
        'is_guest' => $this->context->customer->is_guest,          
        'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation(),        
        'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn(),
        'products_json' => json_encode($productsKelkoo),
        'sales' => $order->getOrdersTotalPaid(),
        'orderid' => $this->id_order
    ));
    /* end Kelkoo Sales Tracking*/

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

<script type="text/javascript">
    var _kkstrack = {
      merchantInfo: [{ country:"COUNTRY", merchantId:"COM_ID" }],
      orderValue: '{$sales}',
      orderId: '{$orderid}',
      basket: {$products_json}
    };
    (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.

    • 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.
    • BLUE VALUES are the required dynamic values that must be “picked up” from your web shop solution and then passed along in the tag. Please note that basic programming is needed for this part. How to do it depends on the programming language your website is coded in and the name of the variables your platform uses to store this information. Please contact your webmaster or technical team should you require help.
      • {$sales}: any real number with dot as decimal point representing the total amount of the order
      • {$orderid}: any string identifying the order
    • LIGHT BLUE VALUES are additional dynamic values that we recommend you pass along in the tag too for more detailed insights.
      • product_name: any string
      • product_reference: any string identifying the product code
      • product_quantity: any positive integer number representing the number of items for that specific product
      • unit_price_tax_incl: any real number with dot as decimal point representing the price of the single product

If you use PayPal module for payments

If you enabled PayPal payment then you have to change two more files: submit.php and order-confirmation.tpl .
The first file submit.php is located into /modules/paypal/controllers/front/.
Search the following line inside the class PayPalSubmitModuleFrontController (you should find it at line 46)

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

and add this text

    /* Kelkoo Sales Tracking */
    $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(
        'is_guest' => $this->context->customer->is_guest,          
        'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation(),        
        'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn(),
        'products_json' => json_encode($productsKelkoo),
        'sales' => $order->getOrdersTotalPaid(),
        'orderid' => $this->id_order
    ));
    /* end Kelkoo Sales Tracking*/

The second file order-confirmation.tpl is located into /modules/paypal/views/templates/front/.

Add Kelkoo Sales Tracking at the bottom of the file

<script type="text/javascript">
    var _kkstrack = {
      merchantInfo: [{ country:"COUNTRY", merchantId:"COM_ID" }],
      orderValue: '{$sales}',
      orderId: '{$orderid}',
      basket: {$products_json}
    };
    (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.

    • 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, ‘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.
    • BLUE VALUES are the required dynamic values that must be “picked up” from your web shop solution and then passed along in the tag. Please note that basic programming is needed for this part. How to do it depends on the programming language your website is coded in and the name of the variables your platform uses to store this information. Please contact your webmaster or technical team should you require help.
      • {$sales}: any real number with dot as decimal point representing the total amount of the order
      • {$orderid}: any string identifying the order
    • LIGHT BLUE VALUES are additional dynamic values that we recommend you pass along in the tag too for more detailed insights.
      • product_name: any string
      • product_reference: any string identifying the product code
      • product_quantity: any positive integer number representing the number of items for that specific product
      • unit_price_tax_incl: any real number with dot as decimal point representing the price of the single product

Step 2: empty cache (prestashop version 1.6.x and oldest)

  1. go to admin page
  2. go to “advanced” -> “performances”
  3. click on “empty cache” in top/right

Step 3: test implementation

To test your implementation, simply simulate an order placed on your site.

  • Go on your Kelkoo Merchant Extranet and log into your account then click on the link “View your Kelkoo store page” in the top right corner of the Home page
  • Click on one of your offers to be redirected to your website
  • Place an order on your website
  • Save the source code of the confirmation page (as it appears if you do “View” -> “View source”) in case further debugging will be needed
  • The next day go on your Kelkoo Merchant Extranet and log into your account
  • Check in the “Statistics” menu that the sale has been recorded
  • Check that all details have been correctly recorded

Important! Check regularly that sales are being registered. This is extra important to do after you have implemented updates or changes to your site.
If you encounter problems, please use our contact form to send us an email. If the test order was not properly registered in your Statistics page, please attach to your email the source code of the order confirmation page as it appeared (“View”> “View Source”). Kelkoo Sales Tracking code should normally be included.