[英]If product quantity is zero display none “Open cart”
I have a shipping info timer on my product page, how can i not display it if my stock is zero, i am running opencart 1.5.5.1. 我的产品页面上有一个运送信息计时器,如果我的库存为零,我正在运行opencart 1.5.5.1,怎么不能显示它。 this is my file : catalog\\controller\\product\\product.php
这是我的文件: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');
}
This is the coundown timer code catalog/view/theme/journal2/template/product/product.tpl 这是计时器的代码目录/视图/主题/新闻2 /模板/product/product.tpl
<div class="cdbox";>
<span class="cdbox_2";>
<img src="../image/data/delivery_van_sml.png">
</span>
<span class="cdbox_0";>
Order Within the next </span>
<br>
<span id="countdownTimer">
00:00.<small>
00</small>
</span>
<p>
<span class="cdbox_1";>
We guarantee same-day Shipping (Monday - Friday) Before 2pm</p>
</span>
</div>
<script type="text/javascript" src="catalog/view/theme/journal2/js/caseSensitiveCountdownTimer.js">
</script>
If product quantity is zero i do not want to show the Script. 如果产品数量为零,我不想显示脚本。 Can anyone help me solve this please.
谁能帮我解决这个问题。
Just add a stock flag to controller (if there is no other way to get it in tpl) wrap your HTML/JS snippet in PHP conditional statement. 只需向控制器添加一个stock标志(如果没有其他方法可以将其放入tpl中),则将您的HTML / JS代码片段包装在PHP条件语句中。
Try something like below: 尝试以下内容:
Not tested 未测试
In controller: 在控制器中:
$this->data['in_stock'] = false;
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'];
$this->data['in_stock'] = true;
} else {
$this->data['stock'] = $this->language->get('text_instock');
$this->data['in_stock'] = true;
}
In tpl: 在tpl中:
<?php if($in_stock) { ?>
<div class="cdbox";>
<span class="cdbox_2";>
<img src="../image/data/delivery_van_sml.png">
</span>
<span class="cdbox_0";>
Order Within the next </span>
<br>
<span id="countdownTimer">
00:00.<small>
00</small>
</span>
<p>
<span class="cdbox_1";>
We guarantee same-day Shipping (Monday - Friday) Before 2pm</p>
</span>
</div>
<script type="text/javascript" src="catalog/view/theme/journal2/js/caseSensitiveCountdownTimer.js">
</script>
<?php } ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.