/** * Perform address validation on checkout billing address */ public function saveBillingAction() { $this->_addressType = 'billing'; 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::saveBillingAction(); } }
public function saveBillingAction() { if (!Mage::helper('sujoy_checkout')->getHideShipping()) { parent::saveBillingAction(); return; } if ($this->_expireAjax()) { return; } if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getPost('billing', array()); $customerAddressId = $this->getRequest()->getPost('billing_address_id', false); if (isset($data['email'])) { $data['email'] = trim($data['email']); } $result = $this->getOnepage()->saveBilling($data, $customerAddressId); if (!isset($result['error'])) { /* check quote for virtual */ if ($this->getOnepage()->getQuote()->isVirtual()) { $result['goto_section'] = 'payment'; $result['update_section'] = array('name' => 'payment-method', 'html' => $this->_getPaymentMethodsHtml()); } elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) { //add default shipping method $data = Mage::helper('sujoy_checkout')->getDefaultShippingMethod(); $result = $this->getOnepage()->saveShippingMethod($data); $this->getOnepage()->getQuote()->save(); /* $result will have erro data if shipping method is empty */ if (!$result) { Mage::dispatchEvent('checkout_controller_onepage_save_shipping_method', array('request' => $this->getRequest(), 'quote' => $this->getOnepage()->getQuote())); $this->getOnepage()->getQuote()->collectTotals(); $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); $result['goto_section'] = 'payment'; $result['update_section'] = array('name' => 'payment-method', 'html' => $this->_getPaymentMethodsHtml()); } $result['allow_sections'] = array('shipping'); $result['duplicateBillingInfo'] = 'true'; } else { $result['goto_section'] = 'shipping'; } } $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); } }
/** * save checkout billing address */ public function saveBillingAction() { if (!Mage::getStoreConfig('carriers/wsaupsfreight/active')) { return parent::saveBillingAction(); } if ($this->_expireAjax()) { return; } if ($this->getRequest()->isPost()) { $postData = $this->getRequest()->getPost('billing', array()); $data = $this->_filterPostData($postData); $customerAddressId = $this->getRequest()->getPost('billing_address_id', false); if (isset($data['email'])) { $data['email'] = trim($data['email']); } $result = $this->getOnepage()->saveBilling($data, $customerAddressId); if (!isset($result['error'])) { /* check quote for virtual */ if ($this->getOnepage()->getQuote()->isVirtual()) { $result['goto_section'] = 'payment'; $result['update_section'] = array('name' => 'payment-method', 'html' => $this->_getPaymentMethodsHtml()); } elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) { if (Mage::helper('wsaupsfreight')->dontShowConwayFreight($this->getOnepage()->getQuote()->getAllVisibleItems())) { $this->_skipFreight = true; } if ($this->_skipFreight) { $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() );*/ } $result['allow_sections'] = array('shipping'); $result['duplicateBillingInfo'] = 'true'; } else { $result['goto_section'] = 'shipping'; } } $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); } }
/** * save checkout billing address */ public function saveBillingAction() { $saveBillingActionComplete = false; //die(Mage::getSingleton('core/session')->getSecuriyCode()); if ($this->_expireAjax()) { return; } if (!(Mage::getStoreConfig("OutsourceOnline_Captcha/captcha/when_loggedin") && Mage::getSingleton('customer/session')->isLoggedIn())) { if (Mage::getStoreConfig("OutsourceOnline_Captcha/captcha/customer")) { // check response $resp = Mage::helper("outsourceonline_captcha")->validate(); $data = $this->getRequest()->getPost(); //validate botscout Mage::helper("outsourceonline_captcha")->validateBotScout(Mage::getSingleton('core/app')->getRequest()->getParam('nickname')); if ($resp == true) { // if captcha response is correct, use core functionality //parent::saveBillingAction(); } else { // if captcha response is incorrect, reload the page Mage::getSingleton('core/session')->addError($this->__('Your CAPTCHA entry is incorrect. Please try again.')); Mage::getSingleton('review/session')->setFormData($data); $this->_redirectReferer(); $saveBillingActionComplete = true; return; } } /*else { // if captcha is not enabled, use core function alone parent::postAction(); }*/ } if (!$saveBillingActionComplete) { // if captcha is not enabled, use core function alone parent::saveBillingAction(); } }
/** * Perform address validation on checkout billing address */ public function saveBillingAction() { // 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::saveBillingAction(); } // Get posted info $post = $this->getRequest()->getPost('billing', array()); // If posting record from address book set postdata to existing address if ($addressId = $this->getRequest()->getPost('billing_address_id')) { $customer = Mage::getModel('customer/session')->getCustomer(); $existsAddress = $customer->getAddressById($addressId); // Check if this is an existing address of customer if ($existsAddress->getId() && $existsAddress->getCustomerId() == $customer->getId()) { // Set post data to existing address // Needed otherwise it always sends default address $post['street'] = $existsAddress->getStreet(); $post['city'] = $existsAddress->getCity(); $post['region_id'] = $existsAddress->getRegionId(); $post['postcode'] = $existsAddress->getPostcode(); $post['country_id'] = $existsAddress->getCountryId(); } } // 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('billing', $post); // Check if this is an existing address if ($addressId && $existsAddress->getId() && $existsAddress->getCustomerId() == $customer->getId()) { // Set existing address to cleansed data from USPS and save $existsAddress->setId($existsAddress->getId()); $existsAddress->setStreet($post['street']); $existsAddress->setCity($post['city']); $existsAddress->setRegionId($post['region_id']); $existsAddress->setPostcode($post['postcode']); $existsAddress->save(); } } } // Continue processing with core method parent::saveBillingAction(); }
/** * save checkout billing address */ public function saveBillingAction() { 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::saveBillingAction(); } else { $validation_enabled = Mage::helper('addressverification')->getEnabledVerification(); if (!$validation_enabled) { parent::saveBillingAction(); } else { $this->getVerification()->setVerificationLib($validation_enabled); $this->getVerification()->getCheckout()->setShippingWasValidated(false); $this->getVerification()->getCheckout()->setShippingValidationResults(false); $data = $this->getRequest()->getPost('billing', array()); $customerAddressId = $this->getRequest()->getPost('billing_address_id', false); $allow_not_valid = Mage::helper('addressverification')->allowNotValidAddress(); // if not valid addresses allowed for checkout if ($this->_checkChangedAddress($data, 'Billing', $customerAddressId, $validation_enabled)) { $this->getVerification()->getCheckout()->setBillingWasValidated(false); } if ($allow_not_valid) { $bill_was_validated = $this->getVerification()->getCheckout()->getBillingWasValidated(); } else { $bill_was_validated = false; } if ($bill_was_validated) { parent::saveBillingAction(); } else { if (isset($data['email'])) { $data['email'] = trim($data['email']); } $result = $this->getOnepage()->saveBilling($data, $customerAddressId); if (!isset($result['error'])) { // run validation $bill_validate = $this->getVerification()->validate_address('Billing'); if ($bill_validate) { $this->getVerification()->getCheckout()->setBillingWasValidated(true); } else { $this->getVerification()->getCheckout()->setBillingWasValidated(false); } // check if exist validation errors if (isset($bill_validate) && is_array($bill_validate) && isset($bill_validate['error']) && !empty($bill_validate['error'])) { $this->getVerification()->getCheckout()->setShowValidationResults('billing'); $result['update_section'] = array('name' => 'address-validation', 'html' => $this->_getAddressCandidatesHtml()); $this->getVerification()->getCheckout()->setShowValidationResults(false); // clear validation results $this->getVerification()->getCheckout()->setBillingValidationResults(false); $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); return; } // clear validation results $this->getVerification()->getCheckout()->setBillingValidationResults(false); parent::saveBillingAction(); } } } } } }