2016-03-01 46 views
1

我在我的產品頁面上有運輸信息計時器,如果我的庫存爲零,我如何不顯示它,我正在運行opencart 1.5.5.1。這是我的文件: 目錄\控制器\產品\ 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'); 
      } 

這是coundown計時碼 目錄/視圖/主題/ journal2 /模板/產品/ 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&nbsp;&nbsp;</span> 
<br> 
<span id="countdownTimer"> 
00:00.<small> 
00</small> 
</span> 
     <p> 
<span class="cdbox_1";> 
We guarantee same-day Shipping (Monday&nbsp;&#45;&nbsp;Friday) Before 2pm</p> 
</span> 
</div> 
<script type="text/javascript" src="catalog/view/theme/journal2/js/caseSensitiveCountdownTimer.js"> 
</script> 

如果產品數量爲零,我不想顯示腳本。任何人都可以幫我解決這個問題。

+0

在第三方物流文件只需使用一個條件語句 –

+0

這是我的目錄/視圖/主題/ journal2/templ ate/product/product.tpl <?php echo $ text_stock; ?>」><?php echo $ stock; ?> – user3886840

回答

0

只需在控制器中添加一個股票標誌(如果沒有其他方法可以在tpl中獲取)將PHP /條件語句中的HTML/JS代碼片段包裹起來。

嘗試類似如下:

未測試

在控制器:

$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; 
     } 

在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&nbsp;&nbsp;</span> 
<br> 
<span id="countdownTimer"> 
00:00.<small> 
00</small> 
</span> 
     <p> 
<span class="cdbox_1";> 
We guarantee same-day Shipping (Monday&nbsp;&#45;&nbsp;Friday) Before 2pm</p> 
</span> 
</div> 
<script type="text/javascript" src="catalog/view/theme/journal2/js/caseSensitiveCountdownTimer.js"> 
</script> 

<?php } ?> 
相關問題