Opencart - 如何显示除“缺货”以外的所有“库存状态”值?

时间:2018-03-14 08:02:04

标签: opencart

Opencart 2.x / 3.x

嗨,朋友们! 我的头像茶壶一样沸腾:(请帮助解决问题。

我想在类别页面中显示“库存状态”中的所有值,但是当产品数量越来越少时,不显示“缺货”。

我的代码:

No

请告诉我,我需要指定哪些正确的代码,这样我才能看到除“缺货”(product.php - in controller Before: if ($product_info['quantity'] <= 0) { Add: $data['stock_quantity'] = $product_info['quantity']; $data['stock_text'] = $product_info['stock_status']; After: $data['products'][] = array( Add: 'quantity' => $result['quantity'], 'stock_text' => $result['stock_status'], category.php - in controller After: $data['products'][] = array( Add: 'quantity' => $result['quantity'], 'stock_text' => $result['stock_status'], product.tpl - in template <?php if ($stock_status_id != 5) { echo $product['stock_text']; } ?> )以外的所有状态?

Preview

1 个答案:

答案 0 :(得分:3)

在catalog / model / catalog / product.php

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

后:     if ($query->num_rows) { return array( 'product_id' => $query->row['product_id'], 'name' => $query->row['name'],

在catalog / controller / product / category.php

添加:     if($result['stock_status_id'] == 5){ $stock = ''; }else{ $stock = $result['stock_status']; }

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

添加:     'stock' => $stock,

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

在category.tpl

添加:

<?php echo $product['stock']; ?>

在您希望显示库存但在$ product foreach循环中的位置。

将stock_status显示为add_to_cart按钮:

在catalog / model / catalog / product.php

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

后:     if ($query->num_rows) { return array( 'product_id' => $query->row['product_id'], 'name' => $query->row['name'],

在catalog / controller / product / category.php

添加:     if($result['stock_status_id'] == 5){ $data['button_cart'] = $result['stock_status']; }else{ $data['button_cart'] = ''; }

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

这会改变您的“添加到购物车”的状态。按钮到库存状态,如果stock_status_id == 5则文本将保留为&#39;添加到购物车&#39;