-1

Below is add to product code . But I am not getting where the values are storing . Kindly help to find out solution for this . I want to know logic behind this code

public function add($product_id, $qty = 1, $option = array(), $recurring_id = 0) {
    $this->data = array();

    $product['product_id'] = (int)$product_id;

    if ($option) {
        $product['option'] = $option;
    }

    if ($recurring_id) {
        $product['recurring_id'] = (int)$recurring_id;
    }

    $key = base64_encode(serialize($product));

    if ((int)$qty && ((int)$qty > 0)) {
        if (!isset($this->session->data['cart'][$key])) {
            $this->session->data['cart'][$key] = (int)$qty;
        } else {
            $this->session->data['cart'][$key] += (int)$qty;
        }
    }
}
user12342
  • 107
  • 2
  • 12

1 Answers1

1

The product details with options are stored in $key = base64_encode(serialize($product));. Where $this->session->data['cart'][$key] contains the number of quantity added by the customer.

For more details check the getProducts() function on the same page. Where you can find

foreach ($this->session->data['cart'] as $key => $quantity) { 
  .... 
  $product = unserialize(base64_decode($key));
  ....
}
Vidhyut Pandya
  • 1,605
  • 1
  • 14
  • 27