-
Notifications
You must be signed in to change notification settings - Fork 3
/
manage_cart.php
43 lines (22 loc) · 1.49 KB
/
manage_cart.php
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
<?php
session_start();
if(isset($_POST['add_to_cart']))
{
if(isset($_SESSION['mycart']))
{
$item_id = array_column($_SESSION['mycart'],'product_id');
$item_check_id = in_array($_POST['product_id'],$item_id);
if($item_check_id==true)
{
header('location:viewdetail.php?id='.$_POST['product_id'].'&category='.$_POST['product_category'].'');
}else{
$count_card = count($_SESSION['mycart']);
$_SESSION['mycart'][$count_card]=array('name'=>$_POST['product_name'],'price'=>$_POST['product_price'],'product_id'=>$_POST['product_id'],'category'=>$_POST['product_category'],'product_qty'=>$_POST['product_qty'],'product_img'=>$_POST['product_img']);
header('location:viewdetail.php?id='.$_POST['product_id'].'&category='.$_POST['product_category'].'');
}
}else{
$_SESSION['mycart'][0]=array('name'=>$_POST['product_name'],'price'=>$_POST['product_price'],'product_id'=>$_POST['product_id'],'category'=>$_POST['product_category'],'product_qty'=>$_POST['product_qty'],'product_img'=>$_POST['product_img']);
header('location:viewdetail.php?id='.$_POST['product_id'].'&category='.$_POST['product_category'].'');
}
}
?>