Cue4cheap wrote: ↑Mon Dec 16, 2024 3:17 am
ianhaney50 wrote: ↑Mon Dec 16, 2024 1:31 am
I am trying to display the text out of stock if the product quantity is 0 or if there is stock quantity greater than 0 then to display the stock number and the words in stock after the number on the product page
I have the following so far but it's only partly working, it's outputting out of stock if the quantity is 0 and 24 if the product is in stock but not outputting in stock after the number
Code: Select all
{% if stock > 0 %}
<li class="stocknumber">{{ stock }}</li>
{% else %}
<li class="stocknumber">{{ stock }} in stock</li>
{% endif %}
I'm using 3.0.4.0
So you have items in stock so "if stock > 0 " it'll put out this line: <li class="stocknumber">{{ stock }}</li>
I don't see your "out of stock" code.
Mike
Just managed to solve it with the following code
In catalog/controller/product/product.php, I added
Code: Select all
$data['quantity'] = $product_info['quantity'];
Code: Select all
'quantity' => $result['quantity'],
In catalog/view/theme/electronic/template/product/product.twig, I added the following
Code: Select all
{% if quantity <= 0 %}
<li class="stocknumber">Out of stock</li>
{% else %}
<li class="instocknumber">{{ stock }} in stock</li>
{% endif %}