Пример #1
0
 function getData()
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         //load visitedProduct
         //load userinfo bar
         $output['visitedProduct'] = $this->getVisitedProduct();
         $output['userInfo'] = $this->getUserInfo();
         //load product comment and add product to visited list
         $productId = $this->input->post('productId');
         if ($productId != 0) {
             $output['productComment'] = $this->getProductComment($productId);
             $this->addProductCookie($productId);
         }
         //load compare product
         $compareCookie = $this->input->cookie('compareProduct');
         $compareArray = explode(",", $compareCookie);
         array_push($compareArray, 0);
         $compareProduct = new product();
         $compareProduct->where_in('id', $compareArray);
         $compareProduct->get_iterated();
         $this->compareProduct = $compareProduct;
         $this->compareArray = $compareArray;
         $dis['base_url'] = base_url();
         $output['compareProduct'] = $this->load->view('front/includes/compareProductSmall', $dis, true);
         $output['compareArray'] = $compareArray;
         //get number of cart item
         $output['numCart'] = $this->countCartItem();
         $this->output->set_header('Content-type: application/json');
         $this->output->set_output(json_encode($output));
     } else {
         show_404();
     }
 }
Пример #2
0
 function deleteAccessories($productId)
 {
     $sentData = $this->input->post('sendData');
     $sentData = trim($sentData, '-');
     $sentData = explode("-", $sentData);
     array_push($sentData, "0");
     $acc = new product();
     $acc->where_in('id', $sentData);
     $acc->get();
     $product = new Product($productId);
     $product->delete($acc->all, 'accessory');
 }
Пример #3
0
 function compare()
 {
     $this->isCache = false;
     //compare product put from cookie
     $compareCookie = $this->input->cookie('compareProduct');
     $compareArray = explode(",", $compareCookie);
     array_push($compareArray, 0);
     $compareProduct = new product();
     $compareProduct->where_in('id', $compareArray);
     $compareProduct->get_iterated();
     $this->compareProduct = $compareProduct;
     $this->compareArray = $compareArray;
     $this->menu_active = 'compare';
     $dis['base_url'] = base_url();
     $dis['view'] = 'product/product_compare';
     $this->page_title = "So sánh sản phẩm - Di động việt";
     $this->page_description = "So sánh các tính năng sản phẩm";
     $this->page_keyword = "So sánh tính năng sản phẩm";
     $dis['breadcum'] = "So sánh sản phẩm";
     $this->viewfront($dis);
 }
Пример #4
0
 function showCart()
 {
     $step = 1;
     if ($this->uri->segment(2, "") != "") {
         $stepStr = $this->uri->segment(2, "");
         $stepStr = explode("-", $stepStr);
         $step = $stepStr[1];
         if ($step != '2' && $step != '3') {
             show_404();
         }
         if (!$this->_checkLogin()) {
             redirect('dang-nhap/' . 'gio-hang/buoc-' . $step);
         }
     }
     //get product from cookie
     $cartDetail = $this->getCartCookie();
     $product = new product();
     $productList = array(0);
     $store = new store();
     $store->get_iterated();
     $dis['store'] = $store;
     foreach ($cartDetail as $key => $value) {
         array_push($productList, $key);
     }
     $product->where_in('id', $productList);
     $product->get();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $cart = new Cartitem();
         $cart->customer_id = $this->customer->id;
         $cart->shipType = $this->input->post('receiveType');
         $cart->paymentType = $this->input->post('payment');
         $cart->deliverStore_id = $this->input->post('branchReceive');
         $cart->paymentStore_id = $this->input->post('branchPayment');
         $cart->shipName = $this->input->post('info_name');
         $cart->shipEmail = $this->input->post('info_email');
         $cart->shipPhone = $this->input->post('info_phone');
         $cart->shipDescription = $this->input->post('info_description');
         $cart->shipAddress = $this->input->post('info_address');
         $cart->status = enum::CART_WAIT_FOR_PROCESS;
         $cart->save();
         $sum = 0;
         foreach ($product as $row) {
             $cartDetailItem = new Cartdetail();
             $cartDetailItem->cartitem_id = $cart->id;
             $cartDetailItem->product_id = $row->id;
             $cartDetailItem->quantity = $cartDetail[$row->id];
             $cartDetailItem->price = $row->getRealPriceNum();
             $cartDetailItem->productName = $row->name;
             $cartDetailItem->inBox = $row->inBox;
             $cartDetailItem->status = enum::CARTDETAIL_AVAILABLE;
             $cartDetailItem->save();
             $cartDetailItem->clear();
             $itemTotal = $cartDetail[$row->id] * $row->getRealPriceNum();
             $sum += $itemTotal;
         }
         $cart->total = $sum;
         $cart->save();
         $this->sendMailCustomer($cart->id);
         $this->sendMailCustomerService($cart->id);
         //save cart detail
         setcookie("userCart", json_encode(array()), mktime() . time() + 60 * 60 * 24 * 7, "/");
         $dis['view'] = 'cart/cart4';
     } else {
         $dis['step'] = $step;
         $dis['product'] = $product;
         $dis['cartDetail'] = $cartDetail;
         $dis['view'] = 'cart/cart1';
     }
     $dis['base_url'] = base_url();
     $this->viewfront($dis);
 }