Php Opencart中的数量
亲爱的stackoverflow代码专家。我有一个关于opencart股票的问题 前端产品页面有显示库存的选项,可以根据可用性(可用或缺货)或实际数量显示库存 是否可以以其他方式显示它?我希望如果库存数量小于或等于5,那么它应该显示数量,否则显示文本:Available 或者以更复杂的方式,如果产品数量大于5或零,则显示文本,否则以数字显示数量 我理解它可能与../catalog/controller/product/product.php文件有关 我不是编码专家。请帮帮我Php Opencart中的数量,php,opencart,stock,Php,Opencart,Stock,亲爱的stackoverflow代码专家。我有一个关于opencart股票的问题 前端产品页面有显示库存的选项,可以根据可用性(可用或缺货)或实际数量显示库存 是否可以以其他方式显示它?我希望如果库存数量小于或等于5,那么它应该显示数量,否则显示文本:Available 或者以更复杂的方式,如果产品数量大于5或零,则显示文本,否则以数字显示数量 我理解它可能与../catalog/controller/product/product.php文件有关 我不是编码专家。请帮帮我 谢谢。编辑文件cat
谢谢。编辑文件
catalog/controller/product/category.php
步骤:1
查找代码:
if ($this->config->get('config_review_status')) {
$rating = (int)$result['rating'];
} else {
$rating = false;
}
在上述代码下方添加以下内容:
if ($result['quantity'] <= 0) {
$rstock = $result['stock_status'];
} elseif ($this->config->get('config_stock_display')) {
$rstock = "Stoc: " . $result['quantity'];
} else {
$rstock = "In stoc";
}
在上述行之后添加以下内容
'stoc' => $rstock,
步骤3
编辑文件
catalog/view/theme/yourtheme/template/product/category.tpl
查找:
'thumb' => $image,
<div class="cart">
添加以下内容:
<?php echo $product['stoc']; ?>
现在,产品的库存将出现在分类页面中
您可以对搜索执行相同的操作(文件将是search.php和search.tpl-与类别位于同一文件夹中)
您可以在以下位置查看更详细的教程:
以上所有内容都使用相同的思想,但实现方式不同。但这会帮助你解决问题
希望这有帮助。很简单
首先将“显示库存”设置为是
现在
查找(第282行附近)
if($product\u info['quantity']数据['stock']=$product\u info['stock\u status']);
}elseif($this->config->get('config\u stock\u display')){
$this->data['stock']=$product_info['quantity'];
}否则{
$this->data['stock']=$this->language->get('text_instock');
}
取代
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');
}
if($product\u info['quantity']数据['stock']=$product\u info['stock\u status']);
}elseif($this->config->get('config_stock_display')&&$product_info['quantity']data['stock']=$product_info['quantity'];
}否则{
$this->data['stock']=$this->language->get('text_instock');
}
希望这有帮助如果我的问题没有正确提出,或者可能我没有正确理解答案,那么很抱歉。我对分类、搜索或任何其他页面中的OC默认值感到满意。它只在单个产品页面上显示“可用性”。它显示“可用”或“缺货”。或者,如果我们将“是”设置为“显示数量”,则显示数字。仅在该字段中,如果库存为1或2或3或4或5,则显示数字;如果数量超过5,则显示标准文本“可用”,或显示文本“缺货”。
//catalog>controller>product>product.php
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');
}
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');
}