Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- Class Cart
- {
- public $cart = [];
- public $product = [];
- public function __construct(){
- }
- public function add($id, $quantity){
- $this->product['id'] = $id;
- $this->product['quantity'] = $quantity;
- $this->cart[] = $this->product;
- }
- public function update($id, $quantity){
- if(!empty($this->cart[$id]['quantity'])){
- $this->cart[$id]['quantity'] += $quantity;
- }
- }
- public function delete($id){
- unset($this->$cart[$id]);
- }
- public function empty(){
- unset($this->$cart);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement