Replacing "Buy now" button with "Request quote" when price is 0

I have a website that has some products which can be purchased and others that require a quotation.

In BC I used Custom fields within Products details/More options, so that when:

Custom 1: offline-product
Custom 2: enquire

…was entered on a product that I wanted to display “Request a Quote” rather than “Buy now”.

HTML and CSS was then used to hide or unhide relevant Buttons.

I’ve looked into Treepls Product custom items but not having any luck in getting it to work. Would Liquid be a better option?

Any ideas?

Hi @Dave. Welcome to the forum!

Yes, Liquid would work well for this use case.
An IF / ELSE condition could be used around your buttons based on the value of any product properties, eg: base on price being 0:

{% if this.Price <= 0 %}
<button>Request quote</button>
{% else %}
<button>Buy now</button>
{% endif %}

Or, based on custom properties:

{% if this.Custom1 == "offline-product" and this.Custom2 == "enquire" %}
<button>Request quote</button>
{% else %}
<button>Buy now</button>
{% endif %}

See documentation for Products for further info:
https://docs.treepl.co/component-types/module-products

Hi @Adam.Wilson

{% if this.Price <= 0 %}
Request quote
{% else %}
Buy now
{% endif %}

The liquid appears to have worked fine for the trial site but doesn’t appear to work on the live site. It only displays “Request a Quote” whether there is a price or not.

Any ideas?

Since this happened after going live, I’m guessing it’s because you’ll need to assign a currency to your new domain name (under ‘Settings’ > ‘Domains’), else all your prices will be set to zero because there is no currency assigned to display the correct price.

1 Like