Reputation: 49
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
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:
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 Extensions → Modifications and clicking the blue refresh icon:
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:
Upvotes: 4