Advertisement
gurumutant

Shopping Cart dg Session - Proses Add Cart

Feb 2nd, 2020
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.52 KB | None | 0 0
  1. <?php
  2.     // file proses/kategori-proses.php
  3.     require_once("../config.php");
  4.     if (isset($_GET['id'])) {
  5.         $ada = false;
  6.         foreach ($_SESSION['cart'] as $key => $item) {
  7.             if ($key==$_GET['id']) {
  8.                 $ada=true;
  9.             }
  10.         }
  11.         if ($ada) { // produk sdh ada di keranjang
  12.             $_SESSION['cart'][$_GET['id']] += 1;
  13.         } else { // produk blm ada di keranjang
  14.             $_SESSION['cart'][$_GET['id']] = 1;
  15.         }
  16.         header("Location: ../?p=produk"); exit;
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement