Nandos Posted September 30, 2016 Share Posted September 30, 2016 (edited) Hi guys o/ I needed to show my promo dates for products directly in their description pages, so I wrote this code in product.tpl that works fine: <div> {if ($product->specificPrice)} {if $lang_iso=='it'} <strong>Prezzo PROMO {$product->specificPrice['from']|date_format:"%e-%m-%Y"} => {$product->specificPrice['to']|date_format:"%e-%m-%Y"}!</strong></br></br> {elseif $lang_iso=='en'} <strong>PROMO Price {$product->specificPrice['from']|date_format:"%e-%m-%Y"} => {$product->specificPrice['to']|date_format:"%e-%m-%Y"}!</strong></br></br> {/if} {/if} </div> Now i wanted to improve it to check cases and errors, so i did this change: <div> {if ($product->specificPrice)} {if ($product->specificPrice['from'])} {if $lang_iso=='it'} <strong>Prezzo PROMO dal {$product->specificPrice['from']|date_format:"%e-%m-%Y"} al {$product->specificPrice['to']|date_format:"%e-%m-%Y"}!</strong></br></br> {elseif $lang_iso=='en'} <strong>PROMO Price from {$product->specificPrice['from']|date_format:"%e-%m-%Y"} until {$product->specificPrice['to']|date_format:"%e-%m-%Y"}!</strong></br></br> {/if} {else} {if $lang_iso=='it'} <strong>Prezzo PROMO fino al {$product->specificPrice['to']|date_format:"%e-%m-%Y"}!</strong></br></br> {elseif $lang_iso=='en'} <strong>PROMO Price until {$product->specificPrice['to']|date_format:"%e-%m-%Y"}!</strong></br></br> {/if} {/if} {/if} </div> Basically, i want check if there is a specified promo start or not. The problem is this 2nd code doesn't work. I mean yes, it kind of works, but it skips the 2nd check "{if ($product->specificPrice['from'])}" and it generates its definition, even if there isn't a start promo date specified. Now my question is: how can i check properly if there is a promo start date or not? Also, the 1st code fits the language check but apparently not the 2nd one, even if it looks like the same to me. Anyone can help me? Thanks in advance guys o/ Edited November 8, 2016 by Nandos (see edit history) Link to comment Share on other sites More sharing options...
rocky Posted October 1, 2016 Share Posted October 1, 2016 Try: <div> {if is_array($product->specificPrice) && isset($product->specificPrice['to']) && $product->specificPrice['to'] != '0000-00-00 00:00:00'} {if isset($product->specificPrice) && $product->specificPrice['from'] != '0000-00-00 00:00:00'} {if $lang_iso=='it'} <strong>Prezzo PROMO dal {$product->specificPrice['from']|date_format:"%e-%m-%Y"} al {$product->specificPrice['to']|date_format:"%e-%m-%Y"}!</strong></br></br> {elseif $lang_iso=='en'} <strong>PROMO Price from {$product->specificPrice['from']|date_format:"%e-%m-%Y"} until {$product->specificPrice['to']|date_format:"%e-%m-%Y"}!</strong></br></br> {/if} {else} {if $lang_iso=='it'} <strong>Prezzo PROMO fino al {$product->specificPrice['to']|date_format:"%e-%m-%Y"}!</strong></br></br> {elseif $lang_iso=='en'} <strong>PROMO Price until {$product->specificPrice['to']|date_format:"%e-%m-%Y"}!</strong></br></br> {/if} {/if} {/if} </div> Though it really would be better for you to use {l s='PROMO Price until'} to make the strings translatable instead of hardcoding each language. 1 Link to comment Share on other sites More sharing options...
Nandos Posted November 8, 2016 Author Share Posted November 8, 2016 Marked as Solved, thanks again rocky. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now