X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   {if} {else} statement tweaking (https://forum.x-cart.com/showthread.php?t=66401)

MAPerformance 03-14-2013 09:15 AM

{if} {else} statement tweaking
 
I am using a {if} {else} statement to show or hide a Free Shipping graphic on certain items on our shop.

Code:

{if $product.price >= 99.99 && $product.productid ne 20786 && $product.productid ne 17302}
  <img src="image.jpg" />
{else}
  <img src="_spacer.gif"/>
{/if}

This shows my free shipping graphic on items that are $99.99 or more, and shows a blank spacer image if it's less. The problem is I have a handful of items that don't qualify for free shipping even though they are over $99.99. You can see what I did do in the code there to account for those items, but I'm wondering of there's a shorter way of declaring the $productid of these exception items other than what I've already done?

Also, maybe this can be used as a reference for someone else looking to do this ;)

tony_sologubov 03-14-2013 10:21 AM

Re: {if} {else} statement tweaking
 
Quote:

Originally Posted by MAPerformance
I am using a {if} {else} statement to show or hide a Free Shipping graphic on certain items on our shop.

Code:

{if $product.price >= 99.99 && $product.productid ne 20786 && $product.productid ne 17302}
  <img src="image.jpg" />
{else}
  <img src="_spacer.gif"/>
{/if}

This shows my free shipping graphic on items that are $99.99 or more, and shows a blank spacer image if it's less. The problem is I have a handful of items that don't qualify for free shipping even though they are over $99.99. You can see what I did do in the code there to account for those items, but I'm wondering of there's a shorter way of declaring the $productid of these exception items other than what I've already done?

Also, maybe this can be used as a reference for someone else looking to do this ;)


You may want to check this condition in PHP code (in_array() function will be useful) and then assign result to a boolean flag in $product array. It will allow you to check the same condition as something like this in Smarty:

HTML Code:

{if $product.my_free_shipping_flag eq 'Y'}
  <img src="image.jpg" />
{else}
  <img src="_spacer.gif"/>
{/if}


Guess, it looks more elegant.

MAPerformance 03-14-2013 11:44 AM

Re: {if} {else} statement tweaking
 
Thanks for the response. That actually makes me think... maybe we can use the "extra fields" functionality to do something like this? I don't really know how to implement your suggestion without more explicit instructions.


All times are GMT -8. The time now is 06:28 PM.

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