View Single Post
  #5  
Old 09-07-2012, 11:50 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Use Smarty variable in product_details.tpl

What you want to do here is run through a foreach loop.

For example (untested):
PHP Code:
function initTracking () {ldelim}
  {foreach 
from=$orders.0.products item=prod/* This gets the products array from the order, and assigns each to a new variable named "prod"*/
    
try {ldelimTracking.getProduct('UA-XXXX','{$prod.productid}').logAddTo Cart(); {rdelim} catch (e) {ldelim}{rdelim}
  {/foreach}
{
rdelim

Just so you understand better how loops work, consider this annotated code:
PHP Code:
{foreach from=$orders item=order/* Start a foreach loop through the orders array and assign to new variable order */
  
{foreach from=$order.products item=product/* Uses the newly assigned $order variable and accesses its sub-array called products to start a new loop with each instance named product /*
    {$product.productid} /* Prints the product id for the current product from the current order */
  
{/foreach} /* closes the products loop */
{/foreach} /* closes the orders loop */ 
The above example should print each product from each order. It will print all the products from the first order, then all the products from the second order, and so on.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote