Dovrebbe bastare fare così:
Codice PHP:
....
foreach ($this->cart_contents as $key => $val){
...
// $this->cart_contents['cart_total'] += ($val['price'] * $val['qty']); Cancellalo
$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);
}
$this->cart_contents['cart_total'] += $this->cart_contents[$key]['subtotal']; // Aggiungi questo
}
PS: negli if devi mettere $item['discount'] == 1, altrimenti fai un assegnazione
PS2: che succede se $item['discount'] == 0 e $val['qty'] >3 ? non ti perdi il sub_totale?
Dovresti mettere nel primo if:
Codice PHP:
if($val['qty']<=3 || $item['discount'] == 0)