< ?php
@include('components/breadcrumb/breadcrumb.php');
setlocale(LC_MONETARY, 'it_IT.UTF-8');
if(count($_SESSION['CART']) < = 0) {
header("location: /acquistare");
}
if($_POST['login_usr'] & & $_POST['login_pwd']) {
$q = mysqli_query($conn, "SELECT * FROM users WHERE email = '".trim($_POST['login_usr'])."' AND
password = '".md5(trim($_POST['login_pwd']))."'");
$r = mysqli_fetch_array($q);
if(mysqli_num_rows($q)) {
$_SESSION['AUTH'] = $r;
} else {
unset($_SESSION['AUTH']);
}
}
if($getQ[1] == 'logout') {
unset($_SESSION['AUTH']);
header("location: /checkout");
}
?>
< div class = "component-checkout" >
< div class = "container" >
< div class = "row" >
< ?php
if(isset($_SESSION['AUTH'])) {
echo "< input type = \"hidden\" class = \"uid\" value = \"".$_SESSION['AUTH']['id']."\" > ";
}
?>
< div class = "col-12 col-md-8 pb-5" >
< span class = "title" > Dettagli fatturazione< / span >
< span class = "subtitle <?= isset($_SESSION['AUTH']) ? 'd-none' : '';?>" >
< span class = "question>" > Sei già nostro cliente?< / span >
< span class = "toggle-login" > Accedi< / span >
< / span >
< span class = "subtitle <?= isset($_SESSION['AUTH']) ? '' : 'd-none';?>" >
< span class = "question>" > Hai effettuato l'accesso come
<?= $_SESSION['AUTH']['first_name']." ".$_SESSION['AUTH']['last_name'];?> .< / span >
< a href = "/checkout/logout" class = "toggle-logout" > Esci< / a >
< / span >
< form class = "login-form <?= isset($_SESSION['AUTH']) ? 'd-none' :'';?>" action = "/checkout" method = "POST" >
< div class = "row" >
< div class = "col-12 col-md-6" >
< span class = "label" > E-mail< / span >
< input type = "email" name = "login_usr" class = "input-text" >
< / div >
< div class = "col-12 col-md-6" >
< span class = "label" > Password< / span >
< input type = "password" name = "login_pwd" class = "input-text" >
< / div >
< div class = "col-12 mt-4" >
< button class = "button button-brown button-big ml-auto" > Accedi< / button >
< / div >
< / div >
< / form >
< div class = "row new-user-form <?= isset($_SESSION['AUTH']) ? 'logged' :'';?>" >
< div class = "col-12 col-md-6 pr-2 pr-md-4" >
< span class = "label" > Nome *< / span >
< input type = "text" name = "first_name" class = "input input-text"
value="<?= $_SESSION['AUTH']['first_name'];?> "
<?= isset($_SESSION['AUTH']) ? 'disabled' : '';?> required>
< / div >
< div class = "col-12 col-md-6 pr-2 pr-md-4" >
< span class = "label" > Cognome *< / span >
< input type = "text" name = "last_name" class = "input input-text"
value="<?= $_SESSION['AUTH']['last_name'];?> "
<?= isset($_SESSION['AUTH']) ? 'disabled' : '';?> required>
< / div >
< div class = "col-12 col-md-6 pr-2 pr-md-4" >
< span class = "label" > E-mail *< / span >
< input type = "email" name = "email" class = "input input-text"
value="<?= $_SESSION['AUTH']['email'];?> "
<?= isset($_SESSION['AUTH']) ? 'disabled' : '';?> required>
< / div >
< div class = "col-12 col-md-6 pr-2 pr-md-4" >
< span class = "label" > Telefono< / span >
< input type = "tel" name = "phone" class = "input input-text"
value="<?= $_SESSION['AUTH']['phone'];?> "
<?= isset($_SESSION['AUTH']) ? 'disabled' : '';?> >
< / div >
< div class = "col-12 col-md-6 pr-2 pr-md-4" >
< span class = "label" > Indirizzo *< / span >
< input type = "text" name = "address" class = "input input-text"
value="<?= $_SESSION['AUTH']['address'];?> "
<?= isset($_SESSION['AUTH']) ? 'disabled' : '';?> required>
< / div >
< div class = "col-12 col-md-6 pr-2 pr-md-4" >
< span class = "label" > Città *< / span >
< input type = "text" name = "city" class = "input input-text"
value="<?= $_SESSION['AUTH']['city'];?> "
<?= isset($_SESSION['AUTH']) ? 'disabled' : '';?> required>
< / div >
< div class = "col-12 col-md-4 pr-2 pr-md-4 mr-auto" >
< span class = "label" > CAP *< / span >
< input type = "text" name = "zip_code" class = "input input-text"
value="<?= $_SESSION['AUTH']['zip_code'];?> "
<?= isset($_SESSION['AUTH']) ? 'disabled' : '';?> required>
< / div >
< div class = "col-12 col-md-4 pr-2 pr-md-4 mr-auto" >
< span class = "label" > Provincia *< / span >
< ?php
if(isset($_SESSION['AUTH'])) {
echo "< input type = \"text\" name = \"province\" class = \"input input-text \ "
value=\"".$_SESSION['AUTH']['province']."\" disabled required>";
} else {
?>
< select name = "province" class = "input input-select"
<?= isset($_SESSION['AUTH']) ? 'disabled' : '';?> required>
< ?php
foreach($PROV as $k => $p) {
echo "< option value = \"".$k."\" " . ( $ _SESSION [ ' AUTH ' ] [ ' province ' ] = = $ k ? ' selected ' : ' ' ) . " > ".
$p."< / option > ";
}
?>
< / select >
< ?php
}
?>
< / div >
< div class = "col-12 col-md-6 pr-2 pr-md-4 <?= isset($_SESSION['AUTH']) ? 'd-none' : '';?>" >
< span class = "label" > Scegli una password *< / span >
< input type = "password" name = "password" class = "input input-text"
<?= !isset($_SESSION['AUTH']) ? 'required' : '';?> >
< span class = "font-10" > deve essere di almeno 8 caratteri contenere almeno un numero, un carattere maiuscolo, uno minuscolo< / span >
< / div >
< div class = "col-12 col-md-6 pr-2 pr-md-4 <?= isset($_SESSION['AUTH']) ? 'd-none' : '';?>" >
< span class = "label" > Conferma password *< / span >
< input type = "password" name = "password_confirm" class = "input input-text"
<?= !isset($_SESSION['AUTH']) ? 'required' : '';?> >
< / div >
< div class = "col-12 col-md-6 pr-2 pr-md-4" >
< span class = "label" > Vuoi spedire ad un indirizzo diverso?< / span >
< label class = "radio" >
< span class = "radio-label text-grey" > No< / span >
< input type = "radio" name = "other_address" value = "no" checked >
< span class = "mark" > < / span >
< / label >
< label class = "radio" >
< span class = "radio-label text-grey" > Si< / span >
< input type = "radio" name = "other_address" value = "yes" >
< span class = "mark" > < / span >
< / label >
< / div >
< / div >
< div class = "row different-address" >
< div class = "col-12 col-md-6 pr-2 pr-md-4" >
< span class = "label" > Indirizzo *< / span >
< input type = "text" name = "x_address" class = "input input-text" required >
< / div >
< div class = "col-12 col-md-6 pr-2 pr-md-4" >
< span class = "label" > Città *< / span >
< input type = "text" name = "x_city" class = "input input-text" required >
< / div >
< div class = "col-12 col-md-4 pr-2 pr-md-4 mr-auto" >
< span class = "label" > CAP *< / span >
< input type = "text" name = "x_zip_code" class = "input input-text" required >
< / div >
< div class = "col-12 col-md-4 pr-2 pr-md-4 mr-auto" >
< span class = "label" > Provincia *< / span >
< select name = "x_province" class = "input input-select" required >
< ?php
foreach($PROV as $k => $p) {
echo "< option value = \"".$k."\" > ".$p."< / option > ";
}
?>
< / select >
< / div >
< / div >
< / div >
< div class = "col-12 col-md-4 pb-5" >
< span class = "title" > Il tuo ordine< / span >
< span class = "subtitle" > < / span >
< ?php
$total = 0;
foreach($_SESSION['CART'] as $item) {
$q = mysqli_query($conn, "SELECT * FROM products WHERE id = ".$item['pid']);
$r = mysqli_fetch_array($q);
$total += $item['price'] * $item['qty'];
?>
< div class = "row item" >
< div class = "col-6 pl-0" >
<?= $r['type']." - ".$r['name'];?>
< / div >
< div class = "col-3 text-right" >
<?= $item['qty'];?>
< / div >
< div class = "col-3 text-right pr-0" >
<?= money_format('%.2n',$r['price'] * $item['qty']);?>
< / div >
< / div >
< ?php
}
?>
< div class = "row item" >
< div class = "col-6 pl-0" >
Costi di spedizione
< / div >
< div class = "col-6 text-right pr-0" >
<?= money_format('%.2n', 10);?>
< / div >
< / div >
< div class = "row total" >
< div class = "col-6 pl-0" >
Totale tasse incluse
< / div >
< div class = "col-6 text-right pr-0" >
<?= money_format('%.2n', $total + 10);?>
< / div >
< / div >
< div class = "row place" >
<!--
< div class = "col-12 py-2 px-0 font-16 text-bold" >
Hai un coupon?
< button class = "link font-16 text-bold" > Clicca quì per inserirlo< / button >
< / div >
-->
< div class = "col-12 py-2 px-0" >
Le informazioni fornite saranno utilizzate per le finalità descritte nella nostra
< a href = "#" class = "link font-18" > privacy policy< / a >
< / div >
< div class = "col-12 py-2 px-0" >
< label class = "checkbox" >
< span class = "checkbox-label text-grey" > Ho letto e accetto la < a href = "#" class = "link font-18" > privacy policy< / a > e i < a href = "#" class = "link font-18" > termini del servizio< / a > < / span >
< input class = "input" type = "checkbox" name = "privacy" value = "yes" required >
< span class = "mark" > < / span >
< / label >
< / div >
< div class = "col-12 py-2 px-0" >
< button class = "place-order button button-big button-brown" > procedi su paypal< / button >
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >