- Home
- Categorie
- Coding e Sistemistica
- Coding
- sommare subtotali con sconto quantitá in carrello compra
-
sommare subtotali con sconto quantitá in carrello compra
Salve a tutti.
Dopo varie ricerche e prove, ho trovato un carrello di compra in internet che fa quello che mi serve, pero ho bisogno di utilizzare sconti per quantitá.
Ho modificato il codice e posso vedere il subtotale con lo sconto, pero il totale rimane con i valori senza sconto perche moltiplica il prezzo per la quantità e no i subtotali.
Colpa la mia ignoranza non riesco a sommare i subtotali.
allego il codice.
Un grazie a tutti per leggere questo post e per un eventuale aiuto.
Massimo// totale
$this->cart_contents['cart_total'] += ($val['price'] * $val['qty']);$this->cart_contents['total_items'] += $val['qty'];
//codice modificato per sconti
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);
}