AhmedM
AhmedM

Reputation: 49

Hide the "Add to Cart" button in OpenCart 3 if the price is 0

I need a solution to hide the "Add to Cart" button from the product page when the product price is zero. I tried with this code, but the button is not being hidden:

{% if (price > 0) %}
    <input type="button"  value="{{ button_cart }}" data-loading-text="{{ text_loading }}" id="button-cart" class="btn btn-mega btn-lg " />
{% endif %}

How can I hide the "Add to Cart" button in OpenCart 3 if price equals 0?

Upvotes: 0

Views: 1683

Answers (1)

You Old Fool
You Old Fool

Reputation: 22969

The code you posted looks fine and as far as I can see it should work. But there are a couple of reasons why changes to your template might not be getting parsed:

  1. OCMod. If you have any OCMod extensions installed that affect the product template, it gets cached and you will need to refresh the OCMod cache after making any direct edits to the template file. This can be done by going to ExtensionsModifications and clicking the blue refresh icon:

    Enter image description here

  2. Twig Cache: By default, the Twig templating system creates a cache of the template files as well so when you make edits you need to either turn off caching or refresh that cache. There is a small gear icon in the upper right corner of the administrator dashboard that opens a dialog for these settings:

    Enter image description here

    Enter image description here

Upvotes: 4

Related Questions