Visualizzazione dei risultati da 1 a 8 su 8

Visualizzazione discussione

  1. #7
    Utente di HTML.it L'avatar di boots
    Registrato dal
    Oct 2012
    Messaggi
    1,626
    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']<=|| $item['discount'] == 0
    Ultima modifica di boots; 15-11-2016 a 12:02

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.