2017-07-11 6 views
1

カートに同じ商品を2つ以上追加しようとしていますが、問題は新品のものが古いものに置き換わることです。私の最近のカートは私にこの結果を与えた:同じ商品をカートに入れるCodeIgniter

私が欲しいもの
SuperBike 31 

はこのようなものです:

$cart_item = array(
     'id'   => $this->input->post('id'), 
     'productid' => $this->input->post('productid'), 
     'name'   => $this->input->post('name'), 
     'qty'   => $amountReq 
); 

$insert = $this->cart->insert($cart_item); 

    if ($insert) { 
     echo count($this->cart->contents()); 
    } else { 
     echo json_encode(false); 
    } 

どれ回答:

SuperBike 11 
SuperBike 20 

ここでは以下のコードは?ありがとうございます

+0

を使用すると、選択したときにどのようにあなたがカートにアイテムを操作している、説明することができます交換してください。 –

+0

それはうまく動作します。カートに同じアイテムを追加すると、製品の数量が増えます。スーパーバイクをカートに2回追加すると、カートにはカート内のアイテムが1つ表示されますが、クォンティは2になります。 –

答えて

0

これを試すことができます。 system/libraries/Cart.php

で開くcart.phpファイルが

unset($this->_cart_contents[$rowid]); 

if(isset($this->_cart_contents[$rowid])) 
{ 
$this->_cart_contents[$rowid]['qty']++; 
return $rowid; 
} 

unset($this->_cart_contents[$rowid]); 
関連する問題