Jump to content

Hide price and add to cart - PS 1.6


Guest

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

I have located a great blog by @premiumpresta 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:

The blog states:

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:

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

Into:

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 > 1000 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??

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