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. this is my file : 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
<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.
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:
<?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 } ?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.