A Products Price?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
Barrowboy
Forum Members
Forum Members
Posts: 223
Joined: Mon Dec 16, 2013 4:09 pm

A Products Price?

Post 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.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: A Products Price?

Post by Dr.CSS »

Try taking out the ->value part as you just checking to see if the price is empty...
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: A Products Price?

Post by velden »

Try

Code: Select all

{if !empty($entry->price)}{$entry->price|number_format:2}{else}FREE{/if}
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Contact:

Re: A Products Price?

Post 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}
To copy System Information to the forum:
https://docs.cmsmadesimple.org/troubles ... nformation

CMS Made Simple Geekmoots attended:
Nottingham, UK 2012 | Ghent, Belgium 2015 | Leicester, UK 2016
Barrowboy
Forum Members
Forum Members
Posts: 223
Joined: Mon Dec 16, 2013 4:09 pm

Re: A Products Price?

Post by Barrowboy »

Hi Both

Thanks for you help it works a treat.

Regards
Post Reply

Return to “Modules/Add-Ons”