-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddtocartaction.php
More file actions
112 lines (88 loc) · 3.59 KB
/
addtocartaction.php
File metadata and controls
112 lines (88 loc) · 3.59 KB
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
<?php
require 'dbclass.php';
session_start();
$userid = $_SESSION['$user_id'];
if($_POST['action'] == "data"){
$product_id = $_POST['product_id'];
// if(isset($_POST['action'])){
$productobj = new test();
$select_product = $productobj->getProductById($product_id);
foreach($select_product as $v){
$product_name = $v['product_name'] ;
$product_price = $v['price'];
$product_images = $v['product_images'];
}
$cartobj = new cart();
$selct_cart = $cartobj->cartcheckid($userid, $product_id);
if(count($selct_cart)>0){
// $message = "product already added to cart";
$_SESSION['cartalert'] = "product already added to cart";
}
else{
$insert_cart = $cartobj->addToCart($userid,$product_id,$product_name,$product_price,$product_images,1);
// $message = "product added to cart";
$_SESSION['cartalert'] = "product added to cart";
}
// header('location:Nos ordinateurs.php');
$output =
'<div class="alertmessage">
<div class="contentalert">
<p>'.$_SESSION['cartalert'].'</p>
<i class="fa-solid fa-xmark" id="closealert" onclick=this.parentElement.parentElement.remove()></i>
</div>
</div>';
echo $output;
// echo $_SESSION['cartalert'];
}
if($_POST['action'] == "dataqnty"){
$product_qnty_arr = $_POST['product_qnty_arr'];
$product_id = $_POST['product_id'];
$cartsetobj = new cart();
// $cartset = $cartsetobj->updateCartQnt(qnt,product_id);
for($x=0; $x<count($product_id); $x++){
$cartset = $cartsetobj->updateCartQnt($product_qnty_arr[$x], $product_id[$x]);
}
// print_r($product_id) ;
// print_r($product_qnty_arr);
// header('location:espace client.php');
}
if(isset($_POST['product_deleted_id_res'])){
$deletedproduct = $_POST['product_deleted_id_res'];
// deleteProduct
$deletbyidobj = new cart();
for($x=0; $x<count($deletedproduct); $x++){
$deletbyid = $deletbyidobj->deleteProduct($deletedproduct[$x]);
}
}
if($_POST['action'] == "productpage"){
$product_id = $_POST['product_id'];
$productobj = new test();
$select_product = $productobj->getProductById($product_id);
foreach($select_product as $v){
$product_name = $v['product_name'] ;
$product_price = $v['price'];
$product_images = $v['product_images'];
}
$cartobj = new cart();
$selct_cart = $cartobj->cartcheckid($userid, $product_id);
if(count($selct_cart)>0){
// $message = "product already added to cart";
$_SESSION['cartalert'] = "product already added to cart";
}
else{
$insert_cart = $cartobj->addToCart($userid,$product_id,$product_name,$product_price,$product_images,1);
// $message = "product added to cart";
$_SESSION['cartalert'] = "product added to cart";
}
// header('location:Nos ordinateurs.php');
$output =
'<div class="alertmessage">
<div class="contentalert">
<p>'.$_SESSION['cartalert'].'</p>
<i class="fa-solid fa-xmark" id="closealert" onclick=this.parentElement.parentElement.remove()></i>
</div>
</div>';
echo $output;
// echo $_SESSION['cartalert'];
}
?>