1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485
|
<?php
// Connexion au service
include("./global.php");
// Identification des page
$pageid = "panier";
// Supprimer un élément du panier
if(isset($_GET['id'])) {
if(is_numeric($_GET['id'])) {
$db->executeInsert('DELETE FROM panier WHERE id = ?', array($_GET['id']));
$ok = "";
}
}
// Ajouter un code promo
if(isset($_POST['add_code'])) {
$code = ($_POST['code']);
$check_code2 = $db->executeQuery('SELECT COUNT(*) AS count_row FROM codepromo WHERE code = ?', array($code));
if($check_code2[0]["count_row"] == 0)
{
$ok3 = "";
}
$check_code2 = $db->executeQuery('SELECT COUNT(*) AS count_row FROM codepromo WHERE code = ? and activer = ?', array($code,"0"));
if($check_code2[0]["count_row"] == 1)
{
$ok4 = "";
}
$check_code = $db->executeQuery('SELECT COUNT(*) AS count_row FROM codepromo WHERE code = ? and activer = ?', array($code,"1"));
if($check_code[0]["count_row"] == 1)
{
if(empty($errorNews)) {
$date = date("d-m-Y à H:i");
$codepromo = $db->executeQuery("SELECT * FROM codepromo WHERE code = ? ", array($code));
$db->executeInsert('INSERT INTO panier_code (user_id,code,prix) VALUES (?,?,?)', array($userInfo[0]["id"],$code,$codepromo[0]["prix"]));
$ok1 = "";
}
}
}
// Ajouter une livraison
if(isset($_POST['livraison'])) {
$typelivraison = ($_POST['typelivraison']);
if(empty($errorNews)) {
$tarrif = $db->executeQuery("SELECT * FROM livraison_tarrif WHERE pays = ? and type = ? ", array($userInfo[0]["pays"],$typelivraison));
$db->executeInsert('INSERT INTO panier_livraison (user_id,pays,prix,type) VALUES (?,?,?,?)', array($userInfo[0]["id"],$userInfo[0]["pays"],$tarrif[0]['prix'],$tarrif[0]['type']));
$ok5 = "";
}
}
//Supprimer une livraison
if(isset($_GET['supp_livraison'])) {
if(is_numeric($_GET['supp_livraison'])) {
$db->executeInsert('DELETE FROM panier_livraison WHERE id = ?', array($_GET['supp_livraison']));
$ok6 = "";
}
}
//Supprimer un code promo
if(isset($_GET['suppcode'])) {
if(is_numeric($_GET['suppcode'])) {
$db->executeInsert('DELETE FROM panier_code WHERE id = ?', array($_GET['suppcode']));
$ok2 = "";
}
}
?>
<!DOCTYPE html>
<!-- Une réalisation de Dylan tout droit réserver -->
<html lang="fr">
<head>
<?php include './configuration.php'; ?>
<title><?php echo $infoweb[0]["nomdusite"]; ?> | Panier</title>
<?php include './style.php'; ?>
</head>
<body>
<div class="page-wrapper">
<?php include './menu.php'; ?>
<?php if(isset($ok)) { ?>
<script type="text/javascript">Swal.fire({
icon: 'success',
title: 'Articles supprimer du panier.',
showConfirmButton: false,
timer: 2500
})
</script>
<?php } ?>
<?php if(isset($ok1)) { ?>
<script type="text/javascript">Swal.fire({
icon: 'success',
title: 'Code promo ajouter',
showConfirmButton: false,
timer: 2500
})
</script>
<?php } ?>
<?php if(isset($ok2)) { ?>
<script type="text/javascript">Swal.fire({
icon: 'success',
title: 'Code promo supprimer',
showConfirmButton: false,
timer: 2500
})
</script>
<?php } ?>
<?php if(isset($ok3)) { ?>
<script type="text/javascript">Swal.fire({
icon: 'error',
title: 'Oups, ce code promo n\'existe pas!',
showConfirmButton: false,
timer: 2500
})
</script>
<?php } ?>
<?php if(isset($ok4)) { ?>
<script type="text/javascript">Swal.fire({
icon: 'error',
title: 'Oups, ce code promo est désactiver',
showConfirmButton: false,
timer: 2500
})
</script>
<?php } ?>
<?php if(isset($ok5)) { ?>
<script type="text/javascript">Swal.fire({
icon: 'success',
title: 'Frais de livraison ajouter.',
showConfirmButton: false,
timer: 2500
})
</script>
<?php } ?>
<?php if(isset($ok6)) { ?>
<script type="text/javascript">Swal.fire({
icon: 'success',
title: 'Prix de livraison supprimer',
showConfirmButton: false,
timer: 2500
})
</script>
<?php } ?>
<main class="main">
<nav aria-label="breadcrumb" class="breadcrumb-nav">
<div class="container">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="./index"><i class="icon-home"></i></a></li>
<li class="breadcrumb-item active" aria-current="page">Panier</li>
</ol>
</div><!-- End .container -->
</nav>
<div class="container">
<?php
$panniers1 = $db->executeQuery('SELECT * FROM panier WHERE user_id = ?', array($userInfo[0]["id"]));
if ($panniers1[0]['user_id'] == 0)
{ ?>
<center><h2>Panier vide</h2></center>
<?php } else { ?>
<div class="row">
<div class="col-lg-8">
<div class="cart-table-container">
<table class="table table-cart">
<thead>
<tr>
<th class="product-col">Porduit</th>
<th class="price-col">Prix unitaire</th>
<th class="qty-col">Quantité</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<?php $panier = $db->executeQuery('SELECT * FROM panier WHERE user_id = ? ORDER BY id DESC', array($userInfo[0]['id']));
foreach ($panier as $paniers) {
$produits = $db->executeQuery('SELECT * FROM produit WHERE produit = ? ORDER BY id', array($paniers["produit_id"]));
$images = $db->executeQuery('SELECT * FROM produit_image WHERE produit_id = ? ORDER BY id limit 1', array($paniers["produit_id"]));
?>
<tr class="product-row">
<td class="product-col">
<figure class="product-image-container">
<a href="./produit_voir?produit=<?php echo $produits[0]["produit"]; ?>" class="product-image">
<img src="./assets/boutique/<?php echo $images[0]["images"]; ?>" alt="product">
</a>
</figure>
<h2 class="product-title">
<p><span><?php echo $produits[0]["titre"]; ?></span><br>
<span>Taille: <?php echo $paniers["taille"]; ?></span><br>
<span>Couleur: <?php echo $paniers["couleur"]; ?></span><br>
<span>Catégorie: <?php echo $produits[0]["categorie"]; ?></span><br>
<span>Sous catégorie: <?php echo $produits[0]["sous_categorie"]; ?></span><br>
</p>
</h2>
</td>
<td><?php echo $produits[0]["prix"]; ?></td>
<td>
<?php echo $paniers["quantiter"]; ?>
</td>
<td><?php
$montant = ($paniers["quantiter"] * $produits[0]["prix"]);
$total = 0;
$total = $montant + $total;
$superTotal += $total;
echo $total;
?> <a href="./panier?id=<?php echo $paniers["id"]; ?>" title="Remove product" class="btn-remove"><span class="sr-only">Remove</span></a></td>
</tr>
<?php } ?>
</tbody>
<tfoot>
<tr>
<td colspan="4" class="clearfix">
<div class="float-left">
<a href="./index " class="btn btn-outline-secondary">Continuer mes achats</a>
</div><!-- End .float-left -->
<div class="float-right">
<a href="./panier" class="btn btn-outline-secondary btn-update-cart">Relancer le panier</a>
</div><!-- End .float-right -->
</td>
</tr>
</tfoot>
</table>
</div><!-- End .cart-table-container -->
<?php
$panierlive = $db->executeQuery('SELECT * FROM panier_livraison WHERE user_id = ?', array($userInfo[0]["id"]));
if ($panierlive[0]['user_id'] == 0)
{ ?>
<div class="cart-discount">
<h4>Livraison </h4>
<form method="POST">
<div class="input-group">
<select class="form-control" name="typelivraison">
<?php $livraison = $db->executeQuery('SELECT * FROM livraison_tarrif where pays = ? ORDER BY id', array($userInfo[0]['pays']));
foreach ($livraison as $livraisons) {
?>
<option value="<?php echo $livraisons['type']; ?>"><?php echo $livraisons['pays']; ?> - <?php echo $livraisons['description']; ?> - <?php echo $livraisons['prix']; ?> </option>
<?php } ?>
</select>
<button type="submit" name="livraison" class="btn btn-outline-secondary">Valider</button>
</div>
</form>
</div>
<?php } else { ?>
<?php } ?>
<div class="cart-discount">
<h4>Un code promo ?</h4>
<?php
$codepromo_panier = $db->executeQuery('SELECT * FROM panier_code WHERE user_id = ?', array($userInfo[0]["id"]));
if ($codepromo_panier[0]['user_id'] == 0)
{ ?>
<form method="POST">
<div class="input-group">
<input type="text" name="code" class="form-control form-control-sm" placeholder="Entré votre code promo" required>
<div class="input-group-append">
<button class="btn btn-sm btn-primary" type="submit" name="add_code">Appliquer</button>
</div>
</div><!-- End .input-group -->
</form>
<?php } else { ?>
<form action="#">
<div class="input-group">
<input type="text" class="form-control form-control-sm" value="<?php echo $codepromo_panier[0]["code"]; ?>" disabled>
<div class="input-group-append">
<button class="btn btn-sm btn-primary" type="submit" disabled="">Appliquer</button>
</div>
</div><!-- End .input-group -->
</form>
<?php } ?>
</div><!-- End .cart-discount -->
</div><!-- End .col-lg-8 -->
<div class="col-lg-4">
<div class="cart-summary">
<h3>Résumé</h3>
<table class="table table-totals">
<tbody>
<tr>
<td>Sous total</td>
<td><?php
$panniers1 = $db->executeQuery('SELECT * FROM panier WHERE user_id = ?', array($userInfo[0]["id"]));
if ($panniers1[0]['user_id'] == 0)
{ ?>
0.00
<?php } else { ?>
<?php
echo $superTotal;
?>
<?php } ?></td>
</tr>
<?php
$codepromo_panier = $db->executeQuery('SELECT * FROM panier_code WHERE user_id = ?', array($userInfo[0]["id"]));
if ($codepromo_panier[0]['user_id'] == 0)
{ ?>
<?php } else { ?>
<tr>
<td>Code promo</td>
<td>
-<?php echo $codepromo_panier[0]["prix"]; ?> <h5>(<?php echo $codepromo_panier[0]["code"]; ?>) <a href="./panier?suppcode=<?php echo $codepromo_panier[0]["id"]; ?>"><i class="fas fa-trash"></i></a></h5>
</td>
</tr>
<?php } ?>
<!-- Livraison Prix-->
<?php
$panierlivez = $db->executeQuery('SELECT * FROM panier_livraison WHERE user_id = ?', array($userInfo[0]["id"]));
if ($panierlivez[0]['user_id'] == 0)
{ ?>
<?php } else { ?>
<?php
$panierlive = $db->executeQuery('SELECT * FROM panier_livraison WHERE user_id = ? and pays = ?', array($userInfo[0]["id"],"France"));
if ($panierlive[0]['prix'] == 8.00)
{ ?>
<?php if ($superTotal > '99') {?>
<tr>
<td>Prix livraison</td>
<td><?php echo $panierlive[0]["prix"]; ?> <a href="./panier?supp_livraison=<?php echo $panierlive[0]["id"]; ?>"><i class="fas fa-trash"></i></a></td>
</tr>
<?php } else { ?>
<tr>
<td>Prix livraison</td>
<td>Gratuit <a href="./panier?supp_livraison=<?php echo $panierlive[0]["id"]; ?>"><i class="fas fa-trash"></i></a></td>
</tr>
<?php } ?>
<?php } else { ?>
<tr>
<td>Prix livraison</td>
<td><?php echo $panierlivez[0]["prix"]; ?> <a href="./panier?supp_livraison=<?php echo $panierlivez[0]["id"]; ?>"><i class="fas fa-trash"></i></a></td>
</tr>
<?php } ?>
<?php } ?>
<!-- Fin du prix de livraison -->
</tbody>
<tfoot>
<tr>
<td>Total de la commande</td>
<td><?php
$panniers1 = $db->executeQuery('SELECT * FROM panier WHERE user_id = ?', array($userInfo[0]["id"]));
if ($panniers1[0]['user_id'] == 0)
{ ?>
0.00
<?php } else { ?>
<?php
$codepromo_panier = $db->executeQuery('SELECT * FROM panier_code WHERE user_id = ?', array($userInfo[0]["id"]));
if ($codepromo_panier[0]['user_id'] == 0)
{ ?>
<!-- Sans code promo -->
<?php
$panierlive = $db->executeQuery('SELECT * FROM panier_livraison WHERE user_id = ?', array($userInfo[0]["id"]));
if ($panierlive[0]['user_id'] == 0)
{
echo "0.00";
} else {
#Livraison remplis
# Si la livraison et pour la france et qu'elle est normal alors on affiche :
$panierlives = $db->executeQuery('SELECT * FROM panier_livraison WHERE user_id = ? and pays = ?', array($userInfo[0]["id"],"France"));
if ($panierlives[0]['prix'] == 8.00)
{
if ($superTotal > '99') {
# Si la livraison fait + de 99.00 on affiche :
$suptotal = ($superTotal + $panierlives[0]["prix"]);
} else {
#Si elle fait - de 99.00 on affiche :
$suptotal = ($superTotal);
}
} else {
$suptotal = ($superTotal + $panierlive[0]["prix"]);
}
}
# Résultat
echo $suptotal;
?>
<?php } else { ?>
<!-- Avec code promo -->
<?php
$panierlive = $db->executeQuery('SELECT * FROM panier_livraison WHERE user_id = ?', array($userInfo[0]["id"]));
if ($panierlive[0]['user_id'] == 0)
{
echo "0.00";
} else {
#Livraison remplis
# Si la livraison et pour la france et qu'elle est normal alors on affiche :
$panierlives = $db->executeQuery('SELECT * FROM panier_livraison WHERE user_id = ? and pays = ?', array($userInfo[0]["id"],"France"));
if ($panierlives[0]['prix'] == 8.00)
{
if ($superTotal > '99') {
# Si la livraison fait + de 99.00 on affiche :
$suptotal = (- $codepromo_panier[0]["prix"] + $superTotal + $panierlives[0]["prix"]);
} else {
#Si elle fait - de 99.00 on affiche :
$suptotal = (- $codepromo_panier[0]["prix"] + $superTotal);
}
} else {
$suptotal = (- $codepromo_panier[0]["prix"] + $superTotal + $panierlive[0]["prix"]);
}
}
# Résultat
echo $suptotal;
?>
<?php } ?>
<?php } ?></td>
</tr>
</tfoot>
</table>
<?php
$panierlive = $db->executeQuery('SELECT * FROM panier_livraison WHERE user_id = ?', array($userInfo[0]["id"]));
if ($panierlive[0]['user_id'] == 0)
{ ?>
<?php } else { ?>
<div class="checkout-methods">
<?php
/* Les variables suivantes doivent être personnalisées selon vos besoins */
$email_paypal= ''.$infoweb[0]["paypal"].'';/*email associé au compte paypal du vendeur*/
$item_numero = ''.$userInfo[0]['id'].''; /*Numéro du produit en vente*/
$item_prix = ''.$suptotal.''; /*prix du produit*/
$item_nom = ''.$infoweb[0]["nomdusite"].' - Textile'; /*Nom du produit*/
$url_retour= ''.$infoweb[0]["lien2"].'/paiement_valider';/*page de remerciement à créer*/
$url_cancel= ''.$infoweb[0]["lien2"].'/paiement_annulation'; /*page d'annulation d'achat*/
$url_confirmation= ''.$infoweb[0]["lien2"].'/paiement_valider';/*page de confirmation d'achat*/
/* fin déclaration des variables */
echo '
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick"/>
<input type="hidden" name="business" value="'.$email_paypal.'"/>
<input type="hidden" name="item_name" value="'.$item_nom.'"/>
<input type="hidden" name="item_number" value="'.$item_numero.'"/>
<input type="hidden" name="amount" value="'.$item_prix.'"/>
<input type="hidden" name="currency_code" value="EUR"/>
<input type="hidden" name="no_note" value="1"/>
<input type="hidden" name="no_shipping" value="0"/>
<input type="hidden" name="lc" value="FR"/>
<input type="hidden" name="notify_url" value="'.$url_confirmation.'"/>
<input type="hidden" name="cancel_return" value="'.$url_cancel.'">
<input type="hidden" name="return" value="'.$url_retour.'">
<button type="submit" name="submit" class="btn btn-block btn-sm btn-primary"><span>Paiement</span></button>
</form> ';
?>
<?php if($userInfo[0]['developpeur'] == 1) { ?>
<a href="./espace_client/paiement_valider" class="btn btn-block btn-sm btn-primary"><span>Paiement DEV</span></a>
<?php } ?>
</div>
<?php } ?>
<!-- End .checkout-methods -->
</div><!-- End .cart-summary -->
</div><!-- End .col-lg-4 -->
</div><!-- End .row -->
<?php } ?>
</div><!-- End .container -->
<div class="mb-6"></div><!-- margin -->
</main><!-- End .main -->
</div><!-- End .page-wrapper -->
<?php include './footer.php'; ?>
<?php include './menu_mobile.php'; ?>
<?php include './js.php'; ?>
</body>
</html> |