예제 #1
0
 private function confirm()
 {
     if ($this->http->isActive('accept')) {
         if ($this->finalize()) {
             Location::To(URL . 'user/last');
         } else {
             //Location::()
         }
     }
     $user = new User(\Lib\Session::get('id'));
     $shippment = array();
     $name = $user->getFirstName();
     $surname = $user->getSurname();
     $country = $user->getCountry();
     $zipcode = $user->getZipCode();
     $city = $user->getCity();
     $street = $user->getStreet();
     $house = $user->getHousNr();
     $appartment = $user->getAppartmentNr();
     $shippment = array($name, $surname, $country, $zipcode, $city, $street, $house, $appartment);
     foreach ($shippment as $data) {
         if (empty($data)) {
             Location::To(URL . 'user/edition');
         }
     }
     $cart = \Lib\Session::get('cart');
     $price = 0;
     $cart_data = array();
     if (!empty($cart)) {
         foreach ($cart as $key => $product) {
             $order = new Order($product['order_id']);
             if (!$order->getQuantity()) {
                 continue;
             }
             $order->setUserId(\Lib\Session::get('id'));
             $price += $order->getQuantity() * $order->getPrice();
             $order->writeData(true);
             $cart_data[$key]['product_name'] = $order->getProductName();
             $cart_data[$key]['product_price'] = $order->getQuantity() * $order->getPrice();
             $cart_data[$key]['product_quantity'] = $order->getQuantity();
         }
     }
     $this->categories_m = new \models\Categories();
     $this->categories = $this->categories_m->getCategories();
     $this->category_ids = $this->categories_m->getCategoriesIds();
     $this->products_m = new \models\Products();
     $this->d_product = $this->products_m->getDayProduct();
     $shipping_method = $this->http->get('shipping_method');
     $shipping = new Shippment($shipping_method);
     $shipping_cost = $shipping->getCost();
     if (empty($shipping_cost)) {
         Location::To(URL . 'cart/show');
     }
     $method = $this->http->get('shipping_method');
     $this->render('confirm', array('categories' => $this->categories, 'd_product' => $this->d_product, 'shippment' => $shippment, 'price' => $price, 'shipping_cost' => $shipping_cost, 'cart_data' => $cart_data, 'method' => $method, 'ids' => $this->category_ids));
 }
예제 #2
0
 public function addShippingMethod()
 {
     $http = new Http();
     if ($http->isActive('cost')) {
         $return = array();
         $method = $http->post('method');
         $cost = $http->post("cost");
         //echo print_r($http);
         //return ;
         $id = 0;
         if (!empty($method) && !empty($cost)) {
             $shipping_m = new Shippment();
             $shipping_m->setShippingName($method);
             $shipping_m->setCost($cost);
             $id = $shipping_m->writeData();
             $return['id'] = $id;
             $return['cost'] = $shipping_m->getCost();
             $return['method'] = $shipping_m->getShippingName();
         }
         echo json_encode($return);
         //$shipping_m->setCost($cost)
     }
 }