打开购物车。当数量 = 0 时,"Add to Cart" 按钮上只有 "Out of Stock"

Opencart. Only "Out of Stock" on the "Add to Cart" button when the quantities = 0

朋友们,我需要你的帮助。

我想在仓库中的数量变为“0”时在"Add to Cart"按钮上显示"Out of Stock"状态。应该在类别和产品中工作。

我只知道这个解决方案:

controller/product/category.php

之后:$data['products'][] = array(

添加:

'quantity'      => $result['quantity'],   
'my_text'       => $result['stock_status'],

category.twig

替换:{{ button_cart }}

收件人:

{% if product.quantity > 0 %}
{{ button_cart }}
{% else %} 
{{ product.my_text }}
{% endif %}

但是这个方法显示了所有的状态,但我只需要"out of stock"(id=5)并应用disabled="disabled"。应显示其他状态名称且不带 "disabled".

我知道从这个开始:

model/catalog/product.php

之后:$query->row['special'],

添加:'stock_status_id' => $query->row['stock_status_id'],

但下一步是什么?

对不起我的英语。我正在使用 Google 翻译。

在catalog/controller/product/category.php:

添加-

if($result['quantity'] > 0){
              $cart = 'ena';
                $cart_text = $this->language->get('button_cart');
}
elseif($result['stock_status_id'] = 5 || $result['quantity'] <= 0){
                $cart = 'dis';
                $cart_text = 'Out Of Stock';
            }

之前 -

$data['products'][] = array(

添加 -

'cart_text'   => $cart_text,
                'cart'        => $cart,

在-

之后
$data['products'][] = array(
                'product_id'  => $result['product_id'],
                'thumb'       => $image,
                'name'        => $result['name'],

在catalog/view/product/category.tpl

编辑按钮购物车如下:

 <button type="button" onclick="cart.add('<?php echo $product['product_id']; ?>', '<?php echo $product['minimum']; ?>');" <?php if($product['cart'] == 'dis') { echo 'disabled'; } ?>><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $product['cart_text']; ?></span></button>