-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd-to-cart.php
57 lines (52 loc) · 1.41 KB
/
add-to-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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php include 'functions.php' ?>
<?php
if (isset($_POST['add-to-cart'])) {
$data = $_POST;
$id = $_POST["d_id"];
$quantity = $_POST['quantity'];
if (add_to_cart($id, $quantity)) {
$response = [
'type' => 'success',
'message' => 'Item added successfully',
];
} else {
$response = [
'type' => 'success',
'message' => 'Some Error Occured, Please try again!',
];
}
} else if (isset($_POST['update-to-cart'])) {
$data = $_POST;
$id = $_POST["d_id"];
$quantity = $_POST['quantity'];
if (update_to_cart($id, $quantity)) {
$response = [
'type' => 'success',
'message' => 'Item added successfully',
];
} else {
$response = [
'type' => 'success',
'message' => 'Some Error Occured, Please try again!',
];
}
} else if (isset($_POST['remove-from-cart'])) {
$id = $_POST["d_id"];
if (remove_from_cart($id)) {
$response = [
'type' => 'success',
'message' => 'Item removed from cart',
];
} else {
$response = [
'type' => 'error',
'message' => 'Some Error Occured, Please try again!',
];
}
}
?>
<main>
<div class="internal-header">
<h1><?= $response['message'] ?></h1>
</div>
</main>