Page 1 of 1

A Products Price?

Posted: Sun Jan 04, 2015 3:15 pm
by Barrowboy
Can anyone explain how I can hide the product price if the price field is empty or zero?

Or a method of changing the price to 'Free'

I have tried to hide the price with this code in the template but fails, although it works for other fields.

{if $entry->price->value != ""}
Price:- {$currency_symbol}{$entry->price}
{/if}

Thanks for any help.

Re: A Products Price?

Posted: Sun Jan 04, 2015 10:55 pm
by Dr.CSS
Try taking out the ->value part as you just checking to see if the price is empty...

Re: A Products Price?

Posted: Mon Jan 05, 2015 11:00 am
by velden
Try

Code: Select all

{if !empty($entry->price)}{$entry->price|number_format:2}{else}FREE{/if}

Re: A Products Price?

Posted: Mon Jan 05, 2015 2:03 pm
by paulbaker
Additional bit to velden's code to check for price > 0 (untested):

Code: Select all

{if !empty($entry->price) AND ($entry->price > 0)}{$entry->price|number_format:2}{else}FREE{/if}

Re: A Products Price?

Posted: Mon Jan 05, 2015 4:45 pm
by Barrowboy
Hi Both

Thanks for you help it works a treat.

Regards