Don't insert product in Cart libraries - El Forum - 06-03-2013
[eluser]ebrahimthex[/eluser]
Here is my Controller
Code: public function __construct() {
parent::__construct();
$this->load->model('shopping_card_model');
}
public function add_to_cart($product_id) { // adds a product to cart
$result = $this->shopping_card_model->selectProductByProductId($product_id);
echo '------';
echo '<pre>';
print_r($result);
exit();
$data = array(
'id' => $product_id,
'qty' => $this->input->post('qty',true),
'price' => $result->product_price,
'images' => $result->product_thumb,
'model' => $result->product_model,
'name' => $result->product_title
);
//$this->load->library('Cart');
$this->cart->insert($data);
redirect("shopping_cart/show_cart");
}
and view---------
Code: stdClass Object
(
[product_id] => 16
[user_id] => 1
[product_title] => Plas Point Tshart Yollow
[product_category] => 1
[product_model] => T45200
[product_quantity] => 40
[product_price] => 300
[product_old_price] => 350
[product_colour] => Yollow, Black, green
[product_size] => 24, 26,28,30
[product_description] => Description Here......
[product_keywords] => T-shart, Shart, Panjabi, Seroani
[product_summary] => Summary Here.
[product_thumb] => img/product2a.jpg
[seo_url] => hj225i~plas-point-tshart-yollow
[status] => 1
)
But When I use
Code: public function __construct() {
parent::__construct();
$this->load->model('shopping_card_model');
}
public function add_to_cart($product_id) { // adds a product to cart
$result = $this->shopping_card_model->selectProductByProductId($product_id);
$data = array(
'id' => $product_id,
'qty' => $this->input->post('qty',true),
'price' => $result->product_price,
'images' => $result->product_thumb,
'model' => $result->product_model,
'name' => $result->product_title
);
//$this->load->library('Cart');
$this->cart->insert($data);
echo "IN Cart";
$cart = $this->cart->contents();
echo '<pre>';
print_r($cart);
exit();
redirect("shopping_cart/show_cart");
}
Then I view don't insert any data in Cart and output is
|