Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
64 righe
1.8 KiB
64 righe
1.8 KiB
<? |
|
|
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
|
|
$error = true; |
|
|
|
if (!empty($_SESSION["utente"]) && $_SESSION["utente"]->permission($radice) && $_SESSION["utente"]->permission("mercato") && !empty($_POST['codice_prodotto']) && !empty($_POST['quantita'])) { |
|
|
|
$prodotto = Market::getInfoProduct($_POST['codice_prodotto'], $_POST['codice_oe'], false); |
|
|
|
if(!empty($prodotto)){ |
|
|
|
$quantita = (int) $_POST['quantita']; |
|
$error = false; |
|
$inCart = Market::getProductsInCart($prodotto); |
|
|
|
$tmpQuantita = 0; |
|
|
|
if(!empty($inCart['quantitaProdotto'])){ |
|
$tmpQuantita = $quantita + $inCart['quantitaProdotto']; |
|
}else{ |
|
$tmpQuantita = $quantita; |
|
} |
|
|
|
|
|
// controlla se l'utente ha fatto almeno un ordine minimo |
|
if( |
|
( ($tmpQuantita >= $prodotto['ordineMinimo']) || empty($prodotto['ordineMinimo']) ) |
|
&& |
|
( ($tmpQuantita <= $prodotto['ordineMassimo']) || empty($prodotto['ordineMassimo']) ) |
|
){ |
|
if(Market::updateCart($prodotto, $tmpQuantita)){ |
|
?> |
|
swal({title:js_dict["success-msg"],type:"success"}).then(function(){ |
|
window.location.reload(); |
|
}); |
|
<? |
|
}else{ |
|
?> |
|
swal({title:js_dict.error,html:"<?= __("Errore Aggiunta al carrello")?>",type:"error"}); |
|
<? |
|
} |
|
}else{ |
|
?> |
|
swal({title:js_dict.error,html:"<?= __('Errore Quantitativo Ordine') ?>",type:"error"}); |
|
<? |
|
} |
|
|
|
}else{ |
|
?> |
|
swal({title:js_dict.error,html:"<?= __("Errore Aggiunta al carrello, controllare se è ancora Disponibile")?>",type:"error"}); |
|
<? |
|
} |
|
} |
|
|
|
if($error){ |
|
?> |
|
swal({title:js_dict.error,html:"<?= __("Errore Aggiunta al carrello")?>",type:"error"}); |
|
<? |
|
} |
|
|
|
|
|
?>
|