Quote:
Originally Posted by ben@lrb.co.uk
Previously, I had:
Code:
{if $products[product].productid ne "3491"}
{include file="customer/main/gift_wrap.tpl"}
but although it was including the file fine, it was doing it regardless of the existence of product 3491. Though I guess that could be (a) the double quotes round the product ID (b) the fact that I had the evaluation happening outside the products section??
It would be useful to know why this works for future ref...
Cheers,
Rachael
|
The double quotes are OK but not necessary - smarty/PHP is very forgiving about converting between strings and numbers. $products is an array containing all of the products in the cart. The {section} {/section} loop repeats whats inbetween them changing $product each time to point to the next product within $products. Outside of the {section} {/section} loop the value of $product isn't defined so your test of $products[product].productid won't work. You could have moved it inside the {section}{/section} but then it would include the file once for each product that isn't 3491 in the cart - not what you want. There is no simple function to just ask if productid 3491 exists in the $products array so you have to loop through the array and check every item in the cart. Hence the need for the assign within the {section}{/section} loop to set a flag if product 3491 is found.