EllisLab text mark
Advanced Search
     
Debugging Cart
Posted: 13 November 2012 10:59 PM   [ Ignore ]
Joined: 2012-10-27
4 posts

Hello, could I have some help with this please. This is a add to cart function with a function gett_product in Models. I cannot see what is wrong here, could someone help me please. Parahi

This is in Models which connects to database and used in Controllers with Function add_cart
function get_product()
{
  $product_id = $this->input->post(‘product_id’);

  $query = $this->db->select(‘product_id, product_name, description, price, photopath’);
  $query = $this->db->from(‘product’);
  $query = $this->db->where(‘product_id’, $product_id);
  $query = $this->db->get(’‘);
  return $query->result_array();
}

This is in the Controller called Function add_cart:
public function add_cart()
{
 
  $thisProduct = $this->Cart_model->add_product();
 
  if($thisProduct->num_rows() > 0)
  {

  $data = array(‘id’ => $thisProduct[‘product_id’],
      ‘qty’ => 1,
          ‘price’ => $thisProduct[‘price’],
      ‘name’ => $thisProduct[‘product_name’],
      ‘description’ => $thisProduct[‘description’]
  );
 
  $this->cart->insert($data);
 
  }
 
  $this->load->view(“site_header”);
  $this->load->view(“site_nav”);
  $this->load->view(“shoppingcart”, $data);
  $this->load->view(“site_footer”);
}

 
Posted: 13 November 2012 11:47 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2012-10-27
4 posts

h