Exemplo n.º 1
0
 public function doSelectBillingAddress()
 {
     $this->order->loadAll();
     $this->request->set('step', 'billing');
     $this->initAnonUser();
     $shipments = $this->order->getShipments();
     if (!$this->user->isAnonymous()) {
         $this->separateBillingAndShippingAddresses();
     }
     if (!$this->request->get('sameAsShipping') && $this->order->shippingAddress->get() && $this->order->billingAddress->get() && $this->order->billingAddress->get()->getID() == $this->order->shippingAddress->get()->getID()) {
         $this->order->billingAddress->set(clone $this->order->billingAddress->get());
         $this->order->billingAddress->get()->save();
     }
     if ($this->request->get('sameAsShipping')) {
         $this->order->billingAddress->set(clone $this->order->shippingAddress->get());
         $this->order->billingAddress->get()->save();
         if (!$this->user->isAnonymous()) {
             $this->order->save();
         }
     } else {
         try {
             $res = parent::doSelectAddress();
             if ($res instanceof ActionRedirectResponse && $res->getActionName() == 'selectAddress') {
                 $params = $res->getParamList();
                 if (empty($params['step']) || 'shipping' != $params['step']) {
                     $errorResponse = parent::selectAddress();
                     $errorList = $errorResponse->get('form')->getValidator()->getErrorList();
                     if ($errorList) {
                         return new JSONResponse(array('errorList' => $errorList));
                     }
                 }
             }
         } catch (SQLException $e) {
             //throw $e;
             $this->order->billingAddressID->resetModifiedStatus();
             SessionOrder::save($this->order);
         }
     }
     if ($this->user->isAnonymous()) {
         $this->user->defaultBillingAddress->get()->userAddress->set($this->order->billingAddress->get());
         $this->saveAnonUser($this->user);
     }
     // attempt to pre-select a shipping method
     $this->shippingMethods();
     return $this->getUpdateResponse('shippingMethods');
 }
Exemplo n.º 2
0
 protected function setAddress($step)
 {
     $res = parent::doSelectAddress();
     if ($res instanceof ActionRedirectResponse && $res->getActionName() == 'selectAddress') {
         $params = $res->getParamList();
         if (empty($params['step']) || $step != $params['step']) {
             $errorResponse = parent::selectAddress();
             $errorList = $errorResponse->get('form')->getValidator()->getErrorList();
             if ($errorList) {
                 return new JSONResponse(array('errorList' => $errorList));
             }
         }
     }
 }