Post by simondoc » Thu Sep 01, 2022 4:29 pm

This is a simple mod that takes 2 minutes.
All we are doing is pulling the quantity from the database into a data parameter,
Then switching on the add to cart buttons of that value is not zero.

First we pull the quantity value from the database and into a data parameter:
In file:/catalog/controller/product/product.php

Code: Select all

if ($product_info['quantity'] <= 0) {
Add this line before it:

Code: Select all

$data['stockb'] = $product_info['quantity'];
Save and close the file.

Then we switch the buttons on and off depending on if the value is zero or not with a simple 'if' statement
In file /catalog/view/template/product/product.twig

Code: Select all

<button type="submit" id="button-cart" class="btn btn-primary btn-lg btn-block">{{ button_cart }}</button>
Add this line before it:

Code: Select all

{% if stockb > 0 %}
Add this line after it:

Code: Select all

{% endif %}
I would have posted it in the OC4 section but it looks like I don't have permissions to post there.



Sun Jul 24, 2022 4:20 pm
Who is online

Users browsing this forum: Zack_1 and 5 guests