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

Use Smarty variable in product_details.tpl

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 09-06-2012, 01:59 PM
 
MAPerformance MAPerformance is offline
 

Senior Member
  
Join Date: Dec 2005
Posts: 145
 

Default Use Smarty variable in product_details.tpl

I am trying to edit the skin\customer\main\product_details.tpl to display a button/link. The code I'm trying to implement needs the PRODUCTID to call the appropriate item, but I'm not sure how to call that in HTML. Here's the code snippet I'm trying to put the PRODUCTID in ("SKU" after the UA-XXXX part):

<param name="flashvars" value="video=http://website.com/video/get/UA-XXXX/SKU&amp;backcolor=0x000000&amp;frontcolor=0xCCCCCC &amp;
lightcolor=0x557722&amp;allowfullscreen=false&amp; auto-play=false&amp;ShowLogo=1&amp;play_on_click=true" />
__________________
www.maperformance.com

X-Cart Version: 4.4.3 Gold
Reply With Quote
  #2  
Old 09-07-2012, 05:48 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

Hiyah MAPerformance,

Banged out a quick tutorial to show you how to determine all these variables, I've covered it before, but this gave me a chance to record a quick tip on the subject.

http://youtu.be/lSb0dBP6I98 Duration: 3:04
__________________
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

The following 2 users thank totaltec for this useful post:
ADDISON (09-07-2012), MAPerformance (09-07-2012)
  #3  
Old 09-07-2012, 06:41 AM
 
MAPerformance MAPerformance is offline
 

Senior Member
  
Join Date: Dec 2005
Posts: 145
 

Default Re: Use Smarty variable in product_details.tpl

You know, I knew all of that but couldn't seem to get it to work. Tried again this morning and it worked fine. Thanks!
__________________
www.maperformance.com

X-Cart Version: 4.4.3 Gold
Reply With Quote
  #4  
Old 09-07-2012, 10:21 AM
 
MAPerformance MAPerformance is offline
 

Senior Member
  
Join Date: Dec 2005
Posts: 145
 

Default Re: Use Smarty variable in product_details.tpl

OK, here's one for you

I'm doing a similar thing for catching the product bought for conversion tracking. The code is like this:

function initTracking () {ldelim}
try {ldelim} Tracking.getProduct('UA-XXXX','{$orders.0.products.0.productid}').logAddTo Cart(); {rdelim} catch (e) {ldelim}{rdelim}
{rdelim}

As you can see I've already done some work here, and it does work fine as is. My question is how do you work it so multiple items can be tracked this way? The suggestion from the conversion tracking company is to duplicate the "try { Tracking...catch (e) {}" line and filling the SKU/PRODUCTID spot with each different item. What's the cleanest way to have each PRODUCTID populate these based on how many products the customer buys? Is this right to make sure I cover up to 10 items?

function initTracking () {ldelim}
try {ldelim} Tracking.getProduct('UA-XXXX','{$orders.0.products.0.productid}').logAddTo Cart(); {rdelim} catch (e) {ldelim}{rdelim}
try {ldelim} Tracking.getProduct('UA-XXXX','{$orders.0.products.1.productid}').logAddTo Cart(); {rdelim} catch (e) {ldelim}{rdelim}
try {ldelim} Tracking.getProduct('UA-XXXX','{$orders.0.products.2.productid}').logAddTo Cart(); {rdelim} catch (e) {ldelim}{rdelim}
try {ldelim} Tracking.getProduct('UA-XXXX','{$orders.0.products.3.productid}').logAddTo Cart(); {rdelim} catch (e) {ldelim}{rdelim}
try {ldelim} Tracking.getProduct('UA-XXXX','{$orders.0.products.4.productid}').logAddTo Cart(); {rdelim} catch (e) {ldelim}{rdelim}
try {ldelim} Tracking.getProduct('UA-XXXX','{$orders.0.products.5.productid}').logAddTo Cart(); {rdelim} catch (e) {ldelim}{rdelim}
try {ldelim} Tracking.getProduct('UA-XXXX','{$orders.0.products.6.productid}').logAddTo Cart(); {rdelim} catch (e) {ldelim}{rdelim}
try {ldelim} Tracking.getProduct('UA-XXXX','{$orders.0.products.7.productid}').logAddTo Cart(); {rdelim} catch (e) {ldelim}{rdelim}
try {ldelim} Tracking.getProduct('UA-XXXX','{$orders.0.products.8.productid}').logAddTo Cart(); {rdelim} catch (e) {ldelim}{rdelim}
try {ldelim} Tracking.getProduct('UA-XXXX','{$orders.0.products.9.productid}').logAddTo Cart(); {rdelim} catch (e) {ldelim}{rdelim}
{rdelim}
__________________
www.maperformance.com

X-Cart Version: 4.4.3 Gold
Reply With Quote
  #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

The following user thanks totaltec for this useful post:
MAPerformance (09-12-2012)
  #6  
Old 09-12-2012, 07:59 AM
 
MAPerformance MAPerformance is offline
 

Senior Member
  
Join Date: Dec 2005
Posts: 145
 

Default Re: Use Smarty variable in product_details.tpl

This worked great! Thanks again for your help!
__________________
www.maperformance.com

X-Cart Version: 4.4.3 Gold
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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:36 AM.

   

 
X-Cart forums © 2001-2020