gurumutant icon

Shopping Cart dg Session - Proses Add Cart

gurumutant | PRO | 02/03/20 03:26:25 AM UTC | 0 ⭐ | 632 👁️ | Never ⏰ | []
PHP |

520 B

|

None

|

0 👍

/

0 👎

<?php 
    // file proses/kategori-proses.php
    require_once("../config.php");
    if (isset($_GET['id'])) {
        $ada = false;
        foreach ($_SESSION['cart'] as $key => $item) {
            if ($key==$_GET['id']) {
                $ada=true;
            }
        }
        if ($ada) { // produk sdh ada di keranjang
            $_SESSION['cart'][$_GET['id']] += 1;
        } else { // produk blm ada di keranjang
            $_SESSION['cart'][$_GET['id']] = 1;
        }
        header("Location: ../?p=produk"); exit;
    }

Comments