Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Passing multiple cart items to Javascript code?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 08-16-2012, 11:02 AM
 
MAPerformance MAPerformance is offline
 

Senior Member
  
Join Date: Dec 2005
Posts: 145
 

Default Passing multiple cart items to Javascript code?

I have some Javascript code I need to install on my order success page for conversion tracking, and am not sure how to modify to code to account for multiple items. The code needs a separate line for every item in the order. How do I tell Smarty to do this? See example of the code below.
Code:
order.addItem("[sku-item-1]","[quantity-item-1]","[per-item-cost-item-1]"); order.addItem("[sku-item-2]","[quantity-item-2]","[per-item-cost-item-2]");
__________________
www.maperformance.com

X-Cart Version: 4.4.3 Gold
Reply With Quote
  #2  
Old 08-16-2012, 12:25 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default Re: Passing multiple cart items to Javascript code?

This usually goes inside the foreach loop in customer/main/order_message.tpl. You'll have to create a new loop for $order.products like:
PHP Code:
{foreach from=$order.products item=op}
  
order.addItem("[{$op.productcode}]" ...
{/foreach} 
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote

The following user thanks cherie for this useful post:
MAPerformance (08-20-2012)
  #3  
Old 08-20-2012, 06:13 AM
 
MAPerformance MAPerformance is offline
 

Senior Member
  
Join Date: Dec 2005
Posts: 145
 

Default Re: Passing multiple cart items to Javascript code?

I appreciate the response, but I may have misled you. I am a complete novice when it comes to editing Smarty. Could you elaborate more on what you mean?
__________________
www.maperformance.com

X-Cart Version: 4.4.3 Gold
Reply With Quote
  #4  
Old 08-20-2012, 08:06 AM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default Re: Passing multiple cart items to Javascript code?

{$op.productcode} is the Smarty variable in this foreach loop to use in place of your sku-item-X. You would want to look inside the $order.products array to see what other variables to use for your quantity-item-X and per-item-cost-item-X, such as $op.amount and $op.display_price, respectively.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
  #5  
Old 03-12-2013, 09:25 AM
 
Mhodge@q1w.net Mhodge@q1w.net is offline
 

Advanced Member
  
Join Date: Aug 2012
Posts: 55
 

Default Re: Passing multiple cart items to Javascript code?

I am trying to incorporate Commission Junction tracking pixels in /common_files/customer/main/order_message.tpl and here is the pixel:

<img src=“https://www.emjcd.com/u?CID=xxxxxxx&OID={$order.order.orderid}&TYPE=5634 &ITEM1=3 214sku&AMT1=13.49&QTY1=1&ITEM2=6577sku&AMT2=7.99&Q TY2=2&CURRENCY=USD& METHOD=IMG“ height=”1” width=“20”>

I need to pass multiple ITEM1, ITEM2, ITEM3, ITEM4 and AMT1, AMT2, AMT3, AMT4, QTY1, QTY2, QTY3 QTY4 etc.

If someone could post the exact code I would greatly appreciate it, thanks!

We have a similar pixel on this page (Part of it below) that works properly but I could not figure out how to incorporate the multiple items in the string above:

mpuid={$order.order.orderid}{foreach from=$order.products item="product"}:{$product.productcode|wm_remove|es cape:javascript}:{$product.amount}{/foreach}"

Thanks!!
__________________
Mike
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

   

 
X-Cart forums © 2001-2020