Jump to content

How to make price value read N/A or show nothing at all.


KGI

Recommended Posts

Hello fellow PS operators,

We have been using PS for sometime now and we leave any item that becomes sold out left in the site. The reason for this is that the end users (our potential customers) still search for items which we no longer have or can supply but land up on our site(s) as a result of a search from Google etc and then venture round the site and perhaps make a purchase of something else that is similar.

However we would like to amend the price that is shown to someting like N/A or show no price at all and that it would be automatic upon sell out..

To re-cap - When an item actually seels out the system auto removes the price of the item which has sold out (if poosible it could be a choice of the PS user to allow prices or dis-allow prices on sell out.

Any ideas any one please.

Thanking you in advance and Kind regards

Ian

Link to comment
Share on other sites

You could 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.allow_oosp OR $product.quantity > 0}{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}
{/if}



This will hide the price when a product is out of stock on product listings, unless you choose the "Allow ordering of out-of-stock" product option. You will need to make a similar change in product.tpl.

Link to comment
Share on other sites

Hello NC,

Many thanks for your quick reply. We are currently using Version 1.2.4.0 - 14.807s as we do not want to upgrade just yet. So the data you supplied will be very useful in time. However would the same data apply to the version we are using or is it different.

Kind regards

Ian

Link to comment
Share on other sites

Yes, it will work in PrestaShop v1.2.4 too. The code is just slightly different. Change lines 18-19 from:

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



to:

{if $product.allow_oosp OR $product.quantity > 0}
{if !$priceDisplay || $priceDisplay == 2}{convertPrice price=$product.price}{if $priceDisplay == 2} {l s='+Tx'}{/if}{/if}
{if $priceDisplay}{convertPrice price=$product.price_tax_exc}{if $priceDisplay == 2} {l s='-Tx'}{/if}{/if}
{/if}

Link to comment
Share on other sites

Hi again NC,

Found and amended changes in the product-list.tpl OK but could not find where to make the changes in the product.tpl file could you advise the line to change and is the change the same or a different script.

Thanking you in advance

Ian

Link to comment
Share on other sites

Change lines 186-233 from:

<!-- prices -->


  ...
{if $product->ecotax != 0}

{l s='include'} {convertPrice price=$product->ecotax} {l s='for green tax'}
{/if}




to:

{if $product.allow_oosp OR $product.quantity > 0}
<!-- prices -->


  ...
{if $product->ecotax != 0}

{l s='include'} {convertPrice price=$product->ecotax} {l s='for green tax'}
{/if}
{/if}



I had to abbreviate a few lines to ... so that it would fit in a post. Basically, you are just adding the if statement at the top and bottom.

Link to comment
Share on other sites

HI NC - Was able to locate and make the changes as advised. But error on shop came up and in a listing of products (where some would be out of stock and would now show no price) nothing was listed at all - have revetted back the files and all is as was.

Can you shead any light on this please.

Big smile

Ian

Just added this foot note

Is the line of text written correctly ?

{if ($product.allow_oosp OR $product.quantity > 0)}

Link to comment
Share on other sites

You must have made a mistake when copying the code. You can edit config/config.inc.php and temporarily change 'display_errors' from 'off' to 'on' so that you get an error message instead of a blank page.

Now that I think about it, the following would work too:

{if $product.allow_oosp OR $product.quantity > 0}



It means if "Allow orders when out-of-stock" is selected or the product quantity is greater than 0, show the price.

Link to comment
Share on other sites

Hi NC,

Sorry to say another failed attempt :(

Have copied, pasted and removed script correctly and still the 1/2 page of content does not show. (double and treble checked it many times)

Any further ideas!!

Cheers

Ian

Link to comment
Share on other sites

  • 9 months later...

Hi Rocky,

 

I'm having a trouble when put this code inside product-list.tpl:

 

{if $product.allow_oosp OR $product.quantity > 0}  
                   <p class="price">
                       {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}
                   </p>

                   {else}
                   	<p class="price">SOLD OUT</p>
                 {/if}

 

This code showing 2 kinds of errors :

1. Many products showing "Sold Out" even it doesn't have any attributes and the quantity is still enough to order.

2. For the products with attributes, if the main attributes' qty is 0, then it shows "Sold Out" in product-list.tpl, so I have to select another attributes to be primary one, and the problem's solved for this part. But it doesn't have to be done manually, right?

 

The question is (probably gonna solve the problems)...

 

Is it possible to change the $product.quantity to SELECT data from product id in "product" table that still has a quantity > 0, because I think this code somehow selecting the quantity from "product_attribute" table.

 

Please help me solve this problem asap, or anybody has any advices?

 

Thank you!

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...