_getSession()->{$this->_getDataObj()->getPrimaryKey()} = null; $this->_getDataObj()->setFormDataFields($this->_getNewForm()); $this->_getDataObj()->clearData(); $data = $this->_getDataObj()->getData(); $form = $this->_getNewForm(['defaults' => $data]); $form->setDefaults(); $this->_addFormItem($form); $this->_postNew(); return $this; } protected function _getNewForm(array $options = []) { $options['orderSummary'] = $this->_getSummaryItem(); if (empty($options['defaults']['id'])) { $options['defaults']['id'] = $this->_getDataObj()->getPrimaryKey(); } return parent::_getNewForm($options); } protected function _prepareRateAjaxData(&$data) { parent::_prepareRateAjaxData($data); $this->_prepareRateData($data); return $this; } /** * Return customer order data * * @return array|bool */ protected function _getCustomerData() { if (null === $this->_customerData) { $customerObj = new App_ECommerce_Order_Admin_Customer_Obj(); $customerObj->setPrimaryKey($this->_getDataObj()->getPrimaryKey()); $customerObj->setFormDataFields(new App_ECommerce_Order_Admin_Customer_Form_New()); $customerData = $customerObj->getData(); $this->_customerData = (!empty($customerData) ? $customerData : false); } return $this->_customerData; } protected function _prepareRateData(&$data) { $customerData = $this->_getCustomerData(); if (!empty($data)) { $data += (array) $customerData; } return $this; } protected function _getUserDataFromSession() { return $this->_getCustomerData(); } protected function _doNext() { if ($this->_isLocked()) { $this->_setBackAttention($this->_createMessage(static::MSG_LOCKED, $this->_getLocker())); $this->_doBack(); } $form = $this->_getNewForm(); if ($form->validate()) { $tabs = App_ECommerce_Order_Admin_View::getTabs(); $backUrl = Qs_SiteMap::findFirst(null, ['type' => 'ECommerce_Order_Admin_Customer_'], null, 'url') . '/' . $tabs->getRestAlias(); $this->_setBackUrl($backUrl); $data = $form->getValues(); $this->_prepareFormData($data); $this->_prepareRateData($data); $orderData = []; $shippingData = $this->_prepareShippingData($data); if (!empty($shippingData)) { $orderData += (array) $shippingData; } $paymentData = $this->_preparePaymentData($data); if (!empty($paymentData)) { $orderData += (array) $paymentData; $primaryKey = $this->_getDataObj()->getPrimaryKey(); $this->_getSession()->{$primaryKey} = $data[App_ECommerce_Checkout_View::PAYMENT_SECTION_DATA]; } $this->_getDataObj()->initFromForm($orderData); if (false === $this->_getDataObj()->update()) { $this->_setBackUrl(Qs_SiteMap::findFirst(null, ['type' => 'ECommerce_Order_Admin_'], null, 'url')); $this->_setBackErrors($this->_getDataObj()->getErrors()); $this->_doBack(); } else { $this->_postInsert(); } $url = BASE_URL_LANGUAGE . '/' . $tabs->getNextTabAlias(); $this->redirect($url); } $this->_addFormItem($form); return $this; } protected function _doApplyPromoCodeAjax() { if ($this->_isLocked()) { $response = [ 'success' => false, 'isLocked' => true, 'error' => $this->_createMessage(static::MSG_LOCKED, $this->_getLocker()), ]; $this->_displayJson($response); } parent::_doApplyPromoCodeAjax(); } protected function _doApplyGiftCardAjax() { if ($this->_isLocked()) { $response = [ 'success' => false, 'isLocked' => true, 'error' => $this->_createMessage(static::MSG_LOCKED, $this->_getLocker()), ]; $this->_displayJson($response); } parent::_doApplyGiftCardAjax(); } protected function _doRemovePromoCodeAjax() { if ($this->_isLocked()) { $response = [ 'success' => false, 'isLocked' => true, 'error' => $this->_createMessage(static::MSG_LOCKED, $this->_getLocker()), ]; $this->_displayJson($response); } parent::_doRemovePromoCodeAjax(); } }