2014-01-09 51 views
1

我想要的是根據選擇的配置更改庫存狀態。更新opencart上的產品選項庫存

如果產品選項有股票期權與數量0節目「缺貨」或數量是50顯示「可用」,並且當是數量-1節目「預購」

if ($product_option_value['quantity'] <= -1) { 
      $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_preorder'); 


if ($product_option_value['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_outstock'); 
     } 



if ($product_option_value['quantity'] => 50) { 
      $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'); 
     } 
+0

那麼需要解決什麼問題? –

+0

它不起作用 – user3063382

+0

它不會作爲'$ this-> data ['stock'] = $ this-> language-> get('text_instock');' - 這段代碼'else'將始終呈現。 –

回答

0
if ($product_option_value['quantity'] <= 0) { 
    $this->data['stock'] = $this->language->get('text_outstock'); 
} elseif ($product_option_value['quantity'] => 50) { 
    $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->data['stock']的值。

+0

它不工作,檢測不到產品選項的數量 – user3063382

+0

輸出是什麼?什麼是預期的產出? –

+0

if($ product_info ['quantity'] <= 0){ \t \t \t \t $ this-> data ['stock'] = $ product_info ['stock_status']; \t \t \t} ELSEIF($這 - > config->得到( 'config_stock_display')){ \t \t \t \t $這 - >數據[ '庫存'] = $產品的詳細信息[ '量']; \t \t \t}否則{ \t \t \t \t $這 - >數據[ '庫存'] = $這個 - >語言 - >的get( 'text_instock'); \t \t \t} – user3063382

相關問題