Beispiel #1
0
 public function add_cart()
 {
     $this->load->helper('convert');
     $id = $this->input->post('id');
     $is_product_existed = $this->Product->check_product_exist($id);
     if (is_numeric($id) && $is_product_existed) {
         $product_info = $this->Product->get_product_info_by_id($id);
         $data = array('id' => $product_info['id'], 'qty' => 1, 'price' => $product_info['price'], 'name' => utf8convert($product_info['product_name']), 'options' => array('image' => $product_info['image']));
         $ok = $this->cart->insert($data);
         if ($ok) {
             $rs['qty'] = $this->cart->total_items();
             $rs['status'] = true;
         } else {
             $rs['status'] = false;
         }
         echo json_encode($rs);
     }
 }
function name_in_url($string)
{
    $string = strtolower(utf8convert($string));
    $string = str_replace(' ', '-', $string);
    return $string;
}