X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Conversion Tracking (https://forum.x-cart.com/showthread.php?t=71780)

xtech 04-07-2015 03:42 AM

Conversion Tracking
 
Hi,
I have found a code in order to track sale but cannot able to add it in x-cart page.
This is the code they have supplied-
Copy first code snippet and paste it in the footer section of your template.
HTML Code:


<script type="text/javascript">var showButton = true;</script>
<script type="text/javascript">var apiKey = "169779d3852b32ce8b1a1724dbf5217d";</script>
<script type="text/javascript" src="//cdn.refiral.com/libs/refiral-1.0.min.js"></script>


and Copy second code snippet and paste it in the footer of your checkout page.
HTML Code:


<script type="text/javascript">var showButton = false;</script>
<script type="text/javascript">var apiKey = "169779d3852b32ce8b1a1724dbf5217d";</script>
<script type="text/javascript" src="//cdn.refiral.com/libs/refiral-1.0.min.js"></script>
<script type="text/javascript">
var customer_name = "CUSTOMER_NAME"; // Replace CUSTOMER_NAME with the customer name
var customer_email = "CUSTOMER_EMAIL"; // Replace CUSTOMER_NAME with the customer email
var grandTotal = "GRAND_TOTAL"; // Replace GRAND_TOTAL with the total amount of the bill of customer
var subTotal = "SUBTOTAL"; // Replace SUBTOTAL with the subtotal amount of the bill of customer
var couponCode = "COUPON_CODE"; // Replace COUPON_CODE with the coupon code applied by customer. Leave it blank if no coupon code is applied.
var order_id = "ORDER_ID"; // Optional
var currency = "CURRENCY"; //Optional

// Push all products to refiral_cart_items array
var refiral_cart_items = [];
refiral_cart_items.push({
  product_id: "P1", // Product ID
  quantity: "2", // Quantity
  name: "Product 1", // Name of product
});
refiral_cart_items.push({
  product_id: "P2", // Item Product ID
  quantity: "1", // Item Quantity
  name: "Product 2", // Name of product
});

invoiceRefiral(subTotal, grandTotal, couponCode, refiral_cart_items, customer_name, customer_email, order_id, currency);
</script>


Now please suggest me where to add.

Thanks,
xtech

xtech 04-08-2015 09:37 PM

Re: Conversion Tracking
 
Can anyone help me please?

Stur 04-08-2015 11:08 PM

Re: Conversion Tracking
 
Unfortunately I'm not familiar with xcart 4 but is there a "Look & Feel" section where you can input custom javascript, like there is with Xcart5?

xtech 04-08-2015 11:46 PM

Re: Conversion Tracking
 
I have added the second set of code in reboot/customer/main/order_message.tpl

HTML Code:


{foreach from=$orders item=order}
{literal}<script type="text/javascript">var showButton = false;</script>{/literal}
{literal}<script type="text/javascript">var apiKey = "169779d3852b32ce8b1a1724dbf5217d";</script>{/literal}
{literal}<script type="text/javascript" src="//cdn.refiral.com/libs/refiral-1.0.min.js"></script>{/literal}
{literal}<script type="text/javascript">
var customer_name ='{$order.s_firstname|escape}&nbsp;{$order.s_lastname|escape}'; // Replace CUSTOMER_NAME with the customer name
var customer_email ='{$order.order.email}'; // Replace CUSTOMER_NAME with the customer email
var grandTotal = '{$order.order.total}'; // Replace GRAND_TOTAL with the total amount of the bill of customer
var subTotal = '{$order.order.display_subtotal}'; // Replace SUBTOTAL with the subtotal amount of the bill of customer
var couponCode = '{$order.order.coupon}'; // Replace COUPON_CODE with the coupon code applied by customer. Leave it blank if no coupon code is applied.
var order_id = '{$order.order.orderid}'; // Optional
var currency = INR; //Optional
// Push all products to refiral_cart_items array
var refiral_cart_items = [];
refiral_cart_items.push({
  product_id: '{$product.productid}', // Product ID
  quantity: '{$product.amount}', // Quantity
  name: '{$product.product}', // Name of product
});
refiral_cart_items.push({
  product_id: '{$product.productid}', // Item Product ID
  quantity: '{$product.amount}', // Item Quantity
  name: '{$product.product}', // Name of product
});

invoiceRefiral(subTotal, grandTotal, couponCode, refiral_cart_items, customer_name, customer_email, order_id, currency);
</script>
{/literal}
  {/foreach}


But it is not working.I want anyone's help in forum.

Thanks.

mcanitano 04-16-2015 06:07 AM

Re: Conversion Tracking
 
well for one, it looks like you have Smarty variables inside literal tags, that is why they aren't populating.

See

http://www.smarty.net/docsv2/en/language.function.literal

http://www.smarty.net/docsv2/en/language.function.ldelim.tpl

Basically when you use {literal} the smarty variables do not work. So you must {/literal}{$smarty.variable}{literal} each time

This is a quick google search on using smarty variables inside literal tags.

http://stackoverflow.com/questions/5001886/how-can-a-smarty-variable-be-made-working-under-literal-literal


As far as your foreach loop. I believe you need a second foreach loop for the products.


You should have one (like you do) for orders, and a separate for the products inside the orders to get variables like {$product.productid}

Try using
Code:

    {foreach from=$order.products item="product"}
// Push all products to refiral_cart_items array
var refiral_cart_items = [];
refiral_cart_items.push({
  product_id: '{$product.productid}', // Product ID
  quantity: '{$product.amount}', // Quantity
  name: '{$product.product}', // Name of product
});
refiral_cart_items.push({
  product_id: '{$product.productid}', // Item Product ID
  quantity: '{$product.amount}', // Item Quantity
  name: '{$product.product}', // Name of product
});
{/foreach}



All times are GMT -8. The time now is 07:32 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.