public function saveShippingAction() { if (!Mage::getStoreConfig('carriers/wsaupsfreight/active')) { return parent::saveShippingAction(); } $this->_expireAjax(); if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getPost('shipping', array()); $customerAddressId = $this->getRequest()->getPost('shipping_address_id', false); $result = $this->getOnepage()->saveShipping($data, $customerAddressId); if (!isset($result['error'])) { if (Mage::helper('wsaupsfreight')->dontShowConwayFreight($this->getOnepage()->getQuote()->getAllVisibleItems())) { $this->_skipFreight = true; $result['goto_section'] = 'shipping_method'; $result['update_section'] = array('name' => 'shipping-method', 'html' => $this->_getShippingMethodsHtml()); } else { $result['goto_section'] = 'shippingextra'; /* $result['update_section'] = array( 'name' => 'shippingextra', 'html' => $this->_getShippingExtraHtml() );*/ } } // $this->loadLayout('checkout_onepage_shippingMethod'); // $result['shipping_methods_html'] = $this->getLayout()->getBlock('root')->toHtml(); // $result['shipping_methods_html'] = $this->_getShippingMethodsHtml(); $this->getResponse()->setBody(Zend_Json::encode($result)); } }
/** * Perform address validation on checkout shipping address */ public function saveShippingAction() { $this->_addressType = 'shipping'; if ($this->shouldCleansePostedAddress()) { $this->cleanseAddress(); } if ($this->_error) { // Return response in JSON $this->getResponse()->setHeader('Content-type', 'application/json'); $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($this->_error)); } else { parent::saveShippingAction(); } }
public function saveShippingAction() { if (!Mage::helper('sujoy_checkout')->getHideShipping()) { parent::saveShippingAction(); return; } if ($this->_expireAjax()) { return; } if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getPost('shipping', array()); $customerAddressId = $this->getRequest()->getPost('shipping_address_id', false); $result = $this->getOnepage()->saveShipping($data, $customerAddressId); $data = Mage::helper('sujoy_checkout')->getDefaultShippingMethod(); $result = $this->getOnepage()->saveShippingMethod($data); $this->getOnepage()->getQuote()->save(); if (!isset($result['error'])) { $result['goto_section'] = 'payment'; $result['update_section'] = array('name' => 'payment-method', 'html' => $this->_getPaymentMethodsHtml()); } $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); } }
/** * Perform address validation on checkout shipping address */ public function saveShippingAction() { // Check if module is enabled and if this is a post if (!Mage::getStoreConfig('checkout/markshust_uspsav/enabled') || !$this->getRequest()->isPost()) { // Continue processing with core method return parent::saveShippingAction(); } // Get posted info $post = $this->getRequest()->getPost('shipping', array()); // Only make this work if USPS Address Verification isn't bypassed // and only for addresses within the United States if (!isset($post['uspsav_bypass']) && isset($post['country_id']) && $post['country_id'] == 'US') { // Get region name from id $regionModel = Mage::getModel('directory/region')->load($post['region_id']); $regionCode = $regionModel->getCode(); // Store address object to pass to USPS $address = (object) array(); $address->address1 = isset($post['street'][1]) ? $post['street'][1] : ''; $address->address2 = isset($post['street'][0]) ? $post['street'][0] : ''; $address->city = isset($post['city']) ? $post['city'] : ''; $address->state = isset($regionCode) ? $regionCode : ''; $address->zip = isset($post['postcode']) ? $post['postcode'] : ''; // Pass the address to USPS to verify and store the XML response if ($result = Mage::helper('markshust_uspsav')->uspsSubmitRequest($address)) { $xml = new SimpleXMLElement($result); $error = Mage::helper('markshust_uspsav')->checkXmlForErrors($xml); } // Exit this method, and pass back (alert) error to user if (isset($error['error'])) { $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($error)); return; } // Set post to the USPS XML response if (isset($xml)) { $correctedRegionModel = Mage::getModel('directory/region')->loadByCode($xml->Address[0]->State, $post['country_id']); $regionId = $correctedRegionModel->getId(); $post['street'][0] = $xml->Address[0]->Address2; $post['street'][1] = $xml->Address[0]->Address1; $post['city'] = $xml->Address[0]->City; $post['region_id'] = $regionId; $post['postcode'] = $xml->Address[0]->Zip5 . '-' . $xml->Address[0]->Zip4; // Set post to the corrected response from USPS $this->getRequest()->setPost('shipping', $post); } } // Continue processing with core method parent::saveShippingAction(); }
/** * Shipping address save action */ public function saveShippingAction() { if ($this->_expireAjax()) { return; } // set results mode (need for javascript logic) $this->getVerification()->getCheckout()->setValidationResultsMode(false); if ($this->getRequest()->isPost()) { if (!Mage::helper('addressverification')->isAddressVerificationEnabled()) { parent::saveShippingAction(); } else { $validation_enabled = Mage::helper('addressverification')->getEnabledVerification(); if (!$validation_enabled) { parent::saveShippingAction(); } else { $this->getVerification()->setVerificationLib($validation_enabled); $data = $this->getRequest()->getPost('shipping', array()); $customerAddressId = $this->getRequest()->getPost('shipping_address_id', false); $allow_not_valid = Mage::helper('addressverification')->allowNotValidAddress(); // if not valid addresses allowed for checkout if ($this->_checkChangedAddress($data, 'Shipping', $customerAddressId, $validation_enabled)) { $this->getVerification()->getCheckout()->setShippingWasValidated(false); } if ($allow_not_valid) { $ship_was_validated = $this->getVerification()->getCheckout()->getShippingWasValidated(); } else { $ship_was_validated = false; } if ($ship_was_validated) { parent::saveShippingAction(); } else { $result = $this->getOnepage()->saveShipping($data, $customerAddressId); if (!isset($result['error'])) { // run validation $ship_validate = $this->getVerification()->validate_address('Shipping'); if ($ship_validate) { $this->getVerification()->getCheckout()->setShippingWasValidated(true); } else { $this->getVerification()->getCheckout()->setShippingWasValidated(false); } // check if exist validation errors if (isset($ship_validate) && is_array($ship_validate) && isset($ship_validate['error']) && !empty($ship_validate['error'])) { $this->getVerification()->getCheckout()->setShowValidationResults('shipping'); $result['update_section'] = array('name' => 'address-validation', 'html' => $this->_getAddressCandidatesHtml()); $this->getVerification()->getCheckout()->setShowValidationResults(false); // clear validation results $this->getVerification()->getCheckout()->setShippingValidationResults(false); $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); return; } // clear validation results $this->getVerification()->getCheckout()->setShippingValidationResults(false); parent::saveShippingAction(); } } } } } }