non riesco a capire come fare,
mi sono accorto che non avevo inserito tutto il codice della funzione, forse magari è più chiaro.
P.S. non ci capisco una mazza... hahahaha
protected function save_cart(){
$this->cart_contents['total_items'] = $this->cart_contents['cart_total'] = 0;
foreach ($this->cart_contents as $key => $val){
// make sure the array contains the proper indexes
if(!is_array($val) OR !isset($val['price'], $val['qty'])){
continue;
}
$this->cart_contents['cart_total'] += ($val['price'] * $val['qty']);
$this->cart_contents['total_items'] += $val['qty'];
if ($val['qty']<=3) {
$this->cart_contents[$key]['subtotal'] = ($this->cart_contents[$key]['price'] * $this->cart_contents[$key]['qty']);
}
if (($val['qty']>=4) && ($item['discount'] = 1)) {
$this->cart_contents[$key]['subtotal'] = ($this->cart_contents[$key]['price'] * $this->cart_contents[$key]['qty']/1.10);
}
if (($val['qty']>=8) && ($item['discount'] = 1)){
$this->cart_contents[$key]['subtotal'] = ($this->cart_contents[$key]['price'] * $this->cart_contents[$key]['qty']/1.15);
}
if (($val['qty']>=12) && ($item['discount'] = 1)){
$this->cart_contents[$key]['subtotal'] = ($this->cart_contents[$key]['price'] * $this->cart_contents[$key]['qty']/1.20);
}
if (($val['qty']>15) && ($item['discount'] = 1)) {
$this->cart_contents[$key]['subtotal'] = ($this->cart_contents[$key]['price'] * $this->cart_contents[$key]['qty']/1.30);
}
}