简体   繁体   English

Opencart中的数量

[英]Quantity in Opencart

Dear stackoverflow code experts. 尊敬的stackoverflow代码专家。 I have a query relating to opencart stock. 我有一个有关opencart库存的查询。

The frontend product page has option of displaying Stock, either in terms of availability (Available or Out of Stock) or in terms of quantity in actual numbers. 前端产品页面具有显示库存的选项,可以是可用性(可用或无库存),也可以是数量(按实际数量)。

Is it possible to display it in some other way? 是否可以其他方式显示它? eg. 例如。 I want that if the stock quantity is less than or equal to 5, then it should display quantity, else display the text: Available. 我希望如果库存数量小于或等于5,则应该显示数量,否则显示文本:Available。

Or in a more sophisticated manner, if product quantity is greater than 5 or zero, then display text, else display quantity in number. 或者,以更复杂的方式,如果产品数量大于5或零,则显示文本,否则显示数量。

I understand it may have to do something with ../catalog/controller/product/product.php file. 我了解它可能与../catalog/controller/product/product.php文件有关。

I am not an expert in coding. 我不是编码专家。 Please help me. 请帮我。

Thank you. 谢谢。

Edit the file catalog/controller/product/category.php 编辑文件catalog/controller/product/category.php

Step : 1 第1步

Find the code: 查找代码:

if ($this->config->get('config_review_status')) {
    $rating = (int)$result['rating'];
} else {
    $rating = false;
}

Add the following just below the above code : 在上面的代码下面添加以下内容:

if ($result['quantity'] <= 0) {
    $rstock = $result['stock_status'];
} elseif ($this->config->get('config_stock_display')) {
    $rstock = "Stoc: " . $result['quantity'];
} else {
    $rstock = "In stoc";
}

Step : 2 第2步

Find : 找 :

'thumb' => $image,

Add the following just after the above line 在上一行之后添加以下内容

'stoc' => $rstock,

Step 3 第三步

Edit the file catalog/view/theme/yourtheme/template/product/category.tpl 编辑文件catalog/view/theme/yourtheme/template/product/category.tpl

Find : 找 :

<div class="cart">

Add the following : 添加以下内容:

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

And now the stock will appear for products in category page. 现在,库存将显示在类别页面中。

You can do the same for search (the files would be search.php and search.tpl - in the same folders as the category) 您可以对搜索执行相同操作(文件将为search.php和search.tpl-与类别位于相同的文件夹中)

You can see a more detailed tutorial at : 您可以在以下位置查看更详细的教程:

  1. http://www.aleixcortadellas.com/main/2009/09/09/742/ http://www.aleixcortadellas.com/main/2009/09/09/742/
  2. http://forum.opencart.com/viewtopic.php?t=27137 http://forum.opencart.com/viewtopic.php?t=27137
  3. http://forum.opencart.com/viewtopic.php?t=66506 http://forum.opencart.com/viewtopic.php?t=66506

All of the above uses the same idea, but implemented in different ways. 以上所有方法都使用相同的思想,但是实现方式不同。 But this should help you solve your problem. 但这应该可以帮助您解决问题。

Hope this helps. 希望这可以帮助。

It's simple. 这很简单。

First set "display stock" to Yes 首先将“展示广告资源”设置为是

admin panel>system>setting>options set display stock to "YES"

now 现在

//catalog>controller>product>product.php

Find (around line 282) 查找(第282行附近)

if ($product_info['quantity'] <= 0) {
 $this->data['stock'] = $product_info['stock_status'];
} elseif ($this->config->get('config_stock_display')) {
 $this->data['stock'] = $product_info['quantity'];
} else {
 $this->data['stock'] = $this->language->get('text_instock');
}

Replace With 用。。。来代替

if ($product_info['quantity'] <= 0) {
 $this->data['stock'] = $product_info['stock_status'];
} elseif ($this->config->get('config_stock_display') && $product_info['quantity'] <= 5) {
 $this->data['stock'] = $product_info['quantity'];
} else {
 $this->data['stock'] = $this->language->get('text_instock');
}

Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM