2014-01-09 4 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 ($ this-> config-> ('config_stock_display')를 얻기) { \t \t \t \t this-> 데이터 [ '재고'] = $ product_info [ '양'] $; \t \t \t한다} else { \t \t \t \t $ this-> 데이터 [ '재고'] = $ this-> language-> GET ('text_instock'); \t \t \t – user3063382

관련 문제