Jump to content

Hide the prices when stock is zero


Oliforum

Recommended Posts

Hello,


 


I am looking for a way to remove the price of an item when the stock is zero (unavailable).


 


Purpose : When a product is no more available, I need to keep the product activated on my website because I still want to show it (the product) and I also need the show that the item is unavalable.


So on the product page, I set activated = YES


 


My problem : 


 


- If the product setting for "Available for sale" is YES


 


Then, the system shows that the product is "Sold", put the cart in grey and does not allow to buy it (which is correct). 


BUT My problem : it keeps the price on.


 


- If I set the product setting "Available for Sale" to NO + the setting of the price disactivated.


 


Then, everything is removed :


-> the Price is removed (this is what I want)


-> but also the cart, the availibility status - even unavailable  - are removed (I want to keep them!)


 


Problem comes from the fact that when I set a product on "Available for sale", the system automatically activate the price and there is no way to remove it on the screen (it is shown in grey and protected for modification).


 


What I do until now (my temporary solution)


 


I untick the "availability for sales" and the "price". I must then "manually" change the description of the page to show that the item is SOLD (that is not very convenient). I am not satisfied with this temporary solution because it creates a blank on the page when you open a category. I prefer to show a grey (and disactivated) cart button. 


 


See printscreen : post-527997-0-67357000-1390317023_thumb.jpg


 


My WEBSITE is : www.acknowledged.fr


To have a look to an example : Click on the first category (Watercolors without characters). Then check out the 3rd item (called "Call 911").


 


Running on 1.5.4.1 and the Default Prestashop Theme.


 


Thanks for your ideas.


 


Olivier


Link to comment
Share on other sites

Hello Robin,

 

Thank you very much for your reply.

 

I would be able to make a change in a CSS-type file, but it looks like you suggest a change in a TPL file, that is for me much more difficult to do (I'm not a specialist).

 

I believe what I need to be changed are both : PRODUCT-LIST.TPL and PRODUCT.TPL

 

Regarding PRODUCT-LIST.TPL, there are several occurences of "Price". I don't know exactly what to change and where. The file is attached below :

 

Product-list.pdf

 

Regarding PRODUCT.TPL, I have noticed that they are intersting variable : var "displayPrice" and var "productShowPrice". I wander if it could be a solution to change the definition of these variables. If so, how exactly ?

 

The file is attached below : 

 

Product.pdf

 

Any help would be appreciated.

 

Olivier

Link to comment
Share on other sites

  • 2 months later...

Thanks a lot.

 

For the product list page (product-list.tpl), solution has been found by adding the following statement for the "content price" part :

 

FROM : 

 

<div class="content_price">
{if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}<span class="price" style="display: inline;">

 

INTO : 

 

<div class="content_price">
{if ($product.quantity > 0) && isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}<span class="price" style="display: inline;">

 

For the product page, I don't know how but it works now.

 

Marked as solved.

 

Link to comment
Share on other sites

  • 2 years later...

Hi, guys.

 

I tried to use ($product.quantity > 0) &&

at

{if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}

 

{if ($product.quantity > 0) && $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}

 

Just to hide the price if the quantities = 0. But It isn't worked.

I'm using de version 1.6.1.6

Does someone can help me!?

Link to comment
Share on other sites

  • 6 years later...

Just in case anyone needs this for Presta 1.7 to hide the price and add to cart when either the price is 0 os product out of stock, you can copy over the following files to your child theme

/home/eaddfb17/public_html/themes/YOURTHEME/templates/catalog/_partials/product-add-to-cart.tpl

/home/eaddfb17/public_html/themes/YOURTHEME/templates/catalog/_partials/product-prices.tpl

And then add the following before the blocks you want to hide, i.e {block name='product_add_cart'} and  {block name='product_price_and_shipping'}

 

{if $product.price_amount eq "0"}
<p> YOU CAN ADD TEXT IF YOU WANT FOR WHEN PRICE is 0 or just delete this sentence</p>

{elseif $product.quantity eq "0"}
<p> YOU CAN ADD TEXT IF YOU WANT FOR WHEN QUANTITY is 0 or just delete this sentence</p>

{else}

 

And then after the block, end the if statement using

 

{/if}

 

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