Jump to content

Welcome, Guest!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

haylau

Hide price and add to cart

Recommended Posts

Looking for some code changes,  or a module, that will allow us to set a price as "0".

If the price is "0" then the price should be hidden and replaced with something like "Please ask for a price", and also the add to cart button should also be hidden

This also needs to work with individual attribute combinations.

So for example if a product is available in red, blue and green, and the price of green is "0" then customer will see the price and add to cart for red and blue but when they select green it shows "Please ask for a price" and the add to cart button is hidden

Any ideas?

Link to comment
Share on other sites

I have located a great blog giving some code changes to enable this

https://premiumpresta.com/blog/display-free-instead-0-00-product-prices-prestashop/

It's a little old so may need the odd tweak, but the part I am struggling with is the combinations in product.js:

 

We must also change the way it displays prices for products which have combinations with different products.

To do this edit /root/themes/default-bootstrap/js/product.js and change line 756:

 
 
 
 
 
1
$('#our_price_display').text(formatCurrency(priceWithDiscountsDisplay, currencyFormat, currencySign, currencyBlank)).trigger('change');

Into:

 
 
 
 
 
1
2
3
4
5
if(combination.price == 0) {
    $('#our_price_display').text("Free").trigger('change');
} else {
    $('#our_price_display').text(formatCurrency(priceWithDiscountsDisplay, currencyFormat, currencySign, currencyBlank)).trigger('change');
}

We check whether the combination is 0 and if it is display a text on change event.

 

This works great IF the price is 0 but I need a different price. I want it to be if the price > 100 the display "Please ask for a price"

So the key line is "if(combination.price==0 {

If I change this to anyting apart form 0 then it does not work. So I am guessing that the 0 actual signifies null rather than a numeric value?

Can anyone suggest how to mod this so it works for my scenario??

 

Edited by haylau
Link to comment
Share on other sites

Posted (edited)

A year on from ^^^ and now Version 1.3.0 and need to achieve the above also.

products.js has changed

I need to be able to have Zero Priced £0.00 products, where the Price is suppressed and the Add to Cart disabled (everywhere product is displayed)

The customer needs to select options which then "builds the price" and the product price is displayed / Add To Cart enabled...

[Edit] Actually, my JavaScript modifications actually work, but only when Attribute with YES/NO option added with Price Increase/No Change combination added.
Although I have yet to suppress the default £0.00 value for the price on initial load...
So looks like I'll figure this out in my own time anyway.

Edited by WebMr
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...