public function addToCart()
 {
     $orbit = new Orbit();
     //        if (!UID::isLoggedIn()) {
     $cart = Session::get('cart');
     if (!in_array($this->getQueryString('product_id'), $cart)) {
         Session::append('cart', $this->getQueryString('product_id'));
         $cartPage = Services::get('cart');
         $cartPage->updateCounter();
     }
     $this->view()->loadTemplate('addedcart');
     $this->commitAdd($this->view()->render(), 'body');
     echo Html::AddClass('dialogIsOpen', 'body');
     return;
     //        }
     //        $request = $orbit->get('request/cart', 1, 1, array('client_id' => UID::get('id')));
     //
     //        if (!isset($request['cart']) || $request['cart'] == 0 ) {
     //            $request = $orbit->post('request/addcart', array(
     //                'client_id' => UID::get('id')
     //            ));
     //
     //            if ($request['status'] != 200) {
     //                //TODO: validar erro de criação de carrinho
     //            }
     //        }
     //
     //        $cart = $request['cart'];
     //
     //        $item = $orbit->post('request/additem', array(
     //            'request_id'    => $cart['id'],
     //            'product_id'    => $this->getQueryString('product_id')
     //        ));
     //
     //        $cartPage = Services::get('cart');
     //        $cartPage->updateCounter();
 }
Example #2
0
 public function addAddress()
 {
     $post = $this->getPost();
     $post['address_type'] = 'Residencial';
     $address = $post;
     if (UID::isLoggedIn()) {
         $orbit = new Orbit();
         $result = $orbit->post('client/addclientaddr/' . UID::get('id'), $post);
     } else {
         Session::append('address', $post);
         $result['address_id'] = count(Session::get('address'));
     }
     $address['id'] = $result['address_id'];
     $this->commitReplace('', '#resultzip');
     $asOption = $this->getQueryString('asoption');
     if ($asOption) {
         $tpl = 'addressoption';
     } else {
         $tpl = 'addressitem';
     }
     $this->view()->loadTemplate($tpl);
     $this->view()->setVariable('address', $address);
     $this->commitAdd($this->view()->render(), '#addresslist');
 }