Jump to content

[SOLVED] How to write the price become 'FREE'?


Recommended Posts

You will need to edit all your TPL files, find where the prices are displayed, then add code that checks whether the price is 0 and display 'FREE' if it is. For example, to change the price on the product listings, change line 18 of product-list.tpl (in PrestaShop v1.3.2) from:

{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}



to:

{if $product.price == 0}{l s='FREE'}{elseif !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}

Share this post


Link to post
Share on other sites

Thanks, Rocky. But I found the code in my presta like this:

{if !$priceDisplay || $priceDisplay == 2}
{convertPrice price=$product.price}{if $priceDisplay == 2} {l s='+Tx'}{/if}
{/if}


Where should I insert the {l s='FREE'}?

And is it only in productlist.tpl? If it must be all in tpl files, it'll be hard then...

Regards,

Indo Islamic Store

Share this post


Link to post
Share on other sites
  • 3 weeks later...
  • 2 months later...
  • 1 year later...

Is there a change that this option is included in the upcomming versions and how to do this in the latest version?

 

I also noticed this solution doesn't work. Anyone have a fix for the newer versions?

Share this post


Link to post
Share on other sites

Figured it out... modifying the code from above

 

In product list.tpl there was code:

{displayWtPrice p=$product.price}

 

which I changed to:

{if $product.price == 0}{l s='FREE'}{else}{displayWtPrice p=$product.price}{/if}

 

EDIT:

Though it worked for most the pages... to make the product.tpl page say free, I'm having a bit more trouble with. I also would like to add a <span> tag around the free but can't figure out how to do that either

 

The code I'm seeing is:

{convertPrice price=$product->getPrice(true, NULL, 2)}</span> {if $product->getPrice(true, NULL, 2) != $product->getPrice(false, NULL, 2)}{l s='incl. tax'}{/if}

 

I'm not sure at this point on how to convert that to free as well if it is zero

Share this post


Link to post
Share on other sites
  • 1 year later...
  • 3 months later...

So... after some fidgeting here's how i managed to change price 0 to text:

 

 

product-list.tpl
 
Replaced (2 times):
{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}

with:

{if $product.price == 0}{l s='MY TEXT HERE'}{else}{displayWtPrice p=$product.price}{/if}

To change it in the product view edit the file product.tpl

 
Replace:
{if $priceDisplay >= 0 && $priceDisplay <= 2}
<span id="our_price_display" itemprop="price">{convertPrice price=$productPrice}</span>
<!--{if $tax_enabled  && ((isset($display_tax_label) && $display_tax_label == 1) || !isset($display_tax_label))}
{if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if}
{/if}-->
<meta itemprop="priceCurrency" content="{$currency->iso_code}" />
{/if}

With:

{if $priceDisplay >= 0 && $priceDisplay <= 2 and $productPrice neq 0}
<span id="our_price_display">{convertPrice price=$productPrice}</span>
<!--{if $tax_enabled  && ((isset($display_tax_label) && $display_tax_label == 1) OR !isset($display_tax_label))}
{if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if}
{/if}-->
{else} MY TEXT HERE
{/if}

Worked like a charm for me.. so far ^_^

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More