V
V
Vitaly Melnichuk2017-05-25 21:23:45
PHP
Vitaly Melnichuk, 2017-05-25 21:23:45

Do not show product in RECOMMENDED if it is out of stock Opencart?

I have a problem. You need to do this, if the product is not in stock, then do not show it in prntscr.com/fc27w5 .
I edited /catalog/controller/module/featured.php and added the line

foreach ($products as $product_id) {
      $product_info = $this->model_catalog_product->getProduct($product_id);
      
      if ($product_info) {
      if ($product_info['quantity'] > 0){

But the site displays everything exactly.
In the template I did this prntscr.com/fc28j4
And the result is 0.
How to fix the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
web-mechanic, 2017-05-26
@vitalik_melnichyk

Why do you need the second condition?
if ($product_info) { replace with if ($product_info && $product_info['quantity'] > 0) {
and update the modifier cache just in case

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question