forked from ElisaLeroy/boutique-laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cartClass.php
40 lines (26 loc) · 806 Bytes
/
cartClass.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
<?php
include_once 'data_base.php';
class Cart {
private array $productQuantity;
public function __construct(){
$this->productQuantity=[];
}
public function add($key, $value){
$_SESSION[$key] = 0;
$this->productQuantity=$_SESSION;
}
public function update($idProduct){
if(isset($this->productQuantity[$idProduct])){
$this->productQuantity[$idProduct]+=1;
return $this->productQuantity[$idProduct];
}
}
public function delete($idProduct){
if($this->productQuantity[$idProduct]=0){
unset($this->productQuantity[$idProduct]);
}
}
public function getProductQuantity(){
return $this->productQuantity;
}
}