Jump to content

[SOLVED] need help updating an if statement in product.tpl 1.3->1.4


Recommended Posts

In 1.3 there is a line of how long the sale is going to last:


{if ($product->reduction_price != 0 || $product->reduction_percent != 0) && (($smarty.now|date_format:'%Y-%m-%d' <= $product->reduction_to && $smarty.now|date_format:'%Y-%m-%d' >= $product->reduction_from))}

{l s='sale ends on'} {$product->reduction_to|date_format:'%d/%m/%Y'}{/if}



Now in 1.4 this is different, I managed to reach that far on my own:

var specific_price_to = '{$product->specificPrice.to}';
var specific_price_from = '{$product->specificPrice.from}';

{if ($product->specificPrice.reduction) && ($product->reduction_from == $product->reduction_to OR ($smarty.now|date_format:'%Y-%m-%d' <= $product->reduction_to && $smarty.now|date_format:'%Y-%m-%d' >= $product->reduction_from))}
{l s='sale ends on'} {$product->specificPrice.to|date_format:'%d/%m/%Y'}{/if}



However, if the sale is unlimited time (0000-00-00), it displays the date 30/11/-1. That's where I need help - so it will not show this date in case of unlimited sale.

Do I get it right that if the to and from are same, it 's not unlimited time sale anymore on 1.4?

EDIT: figured it out after 2 hour experimenting session:

{if ($product->specificPrice.reduction) AND ($product->specificPrice.to|date_format:'%Y-%m-%d' >= $smarty.now|date_format:'%Y-%m-%d')}
{l s='sale ends on'} {$product->specificPrice.to|date_format:'%d/%m/%Y'}{/if}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...