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));
     }
 }
 /**
  * Function to save subscriber from Checkout.
  * The parent saveOrder Action from Mage_Checkout_OnepageController will be called
  */
 public function saveOrderAction()
 {
     $customerSession = Mage::getSingleton('customer/session');
     $newsletter = $this->getRequest()->getPost('newsletter');
     if (isset($newsletter['subscribe'])) {
         if ($newsletter['subscribe'] == '1') {
             // Get the Email
             $mail = $this->getOnepage()->getQuote()->getBillingAddress()->getEmail();
             // Get the Email if there is no mail in billing address
             if ($customerSession->isLoggedIn() && empty($mail)) {
                 $mail = $customerSession->getCustomer()->getEmail();
             }
             if ($this->getOnepage()->getQuote()->getCheckoutMethod() == Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER) {
                 Mage::getSingleton('checkout/session')->setNewRegistration(true);
             } else {
                 Mage::getSingleton('checkout/session')->setNewRegistration(false);
             }
             // Register and subscribe the new guest or customer
             Mage::getModel('newsletter/subscriber')->subscribe($mail);
             //Change Status to subscribed if checkout is custome registration
             if ($this->getOnepage()->getQuote()->getCheckoutMethod() == Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER) {
                 $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($mail);
                 if ($subscriber) {
                     $subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED);
                     $subscriber->save();
                 }
             }
         }
     }
     parent::saveOrderAction();
 }
 public function progressAction()
 {
     if (version_compare(Mage::getVersion(), '1.4.1.0', '>=')) {
         $this->getOnepage()->saveSkippedSata('progress');
     }
     return parent::progressAction();
 }
示例#4
0
 public function indexAction()
 {
     if (Mage::helper("apiplugin")->checkPreOrder()) {
         $this->_redirect('checkout/cart');
         return;
     }
     parent::indexAction();
 }
 /**
  * @return Mage_Checkout_OnepageController
  */
 public function preDispatch()
 {
     parent::preDispatch();
     $this->_preDispatchValidateCustomer();
     $checkoutSessionQuote = Mage::getSingleton('checkout/session')->getQuote();
     if ($checkoutSessionQuote->getIsMultiShipping()) {
         $checkoutSessionQuote->setIsMultiShipping(false);
         $checkoutSessionQuote->removeAllAddresses();
     }
     return $this;
 }
示例#6
0
 /**
  * Checkout page
  */
 public function indexAction()
 {
     $quote = $this->getOnepage()->getQuote();
     $items = $quote->getItemsCollection();
     foreach ($items as $item) {
         if ($item->getProductType() == 'conturifurnizori') {
             $this->_redirect('conturifurnizori/inregistrare/');
             return;
         }
     }
     return parent::indexAction();
 }
 /**
  * override for adding desired dropoff and pickup dates
  */
 public function saveShippingMethodAction()
 {
     $dropoffDate = $this->getRequest()->getParam('dropoff_date');
     $pickupDate = $this->getRequest()->getParam('pickup_date');
     $dropoffTime = $this->getRequest()->getParam('dropoff_time');
     $pickupTime = $this->getRequest()->getParam('pickup_time');
     $dropoff = $dropoffDate . ' ' . $dropoffTime;
     $pickup = $pickupDate . ' ' . $pickupTime;
     $this->getOnepage()->getQuote()->setSendDatetime($dropoff);
     $this->getOnepage()->getQuote()->setReturnDatetime($pickup);
     parent::saveShippingMethodAction();
 }
 /**
  * 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 indexAction()
 {
     $scheme = Mage::app()->getRequest()->getScheme();
     if ($scheme == 'http') {
         $secure = false;
     } else {
         $secure = true;
     }
     if (Mage::helper('onecheckout')->isEnable()) {
         $this->_redirect('bc_checkout', array('_secure' => $secure));
         return;
     } else {
         parent::indexAction();
     }
 }
 /**
  * Predispatch: should set layout area
  *
  * @return Mage_Checkout_OnepageController
  */
 public function preDispatch()
 {
     parent::preDispatch();
     $this->_preDispatchValidateCustomer();
     $checkoutSessionQuote = Mage::getSingleton('checkout/session')->getQuote();
     if ($checkoutSessionQuote->getIsMultiShipping()) {
         $checkoutSessionQuote->setIsMultiShipping(false);
         $checkoutSessionQuote->removeAllAddresses();
     }
     if (!$this->_canShowForUnregisteredUsers()) {
         $this->norouteAction();
         $this->setFlag('', self::FLAG_NO_DISPATCH, true);
         return;
     }
     return $this;
 }
 /**
  * Predispatch: should set layout area
  *
  * @return Mage_Checkout_OnepageController
  */
 public function preDispatch()
 {
     // only extend the function in compiler-mode
     if (defined('COMPILER_INCLUDE_PATH')) {
         /*
          * This basically disables the usage ob the /includes/src/__checkout.php file, because there were autoloader problems. ( Mage-205 )
          * The files will be loaded "normally" from the single files, when the verifyPaymentAction from the Payone controller was called
          */
         $sRouteName = $this->getRequest()->getRouteName();
         if ($sRouteName == 'payone_core') {
             $sRouteName = 'checkout';
         }
         if (array_search($sRouteName, self::$_aLoadedScopes) === false) {
             self::_addLoadedScope($sRouteName);
         } else {
             $this->setFlag('', self::FLAG_NO_PRE_DISPATCH, 1);
         }
     }
     return parent::preDispatch();
 }
 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));
     }
 }
 /**
  * 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();
     }
 }
 /**
  * Returns the shipping mthod options HTML in
  * checkout onepage, including a custom warning, 
  * if applicable
  * @return string 
  */
 protected function _getShippingMethodsHtml()
 {
     // Load the extension's Data.php helper
     $helper = Mage::helper('ups_address_validator');
     // Load current customer's session
     $session = Mage::getSingleton("core/session", array("name" => "frontend"));
     // Switch between choice in Admin:
     // 0 - No validation
     // 1 - Warn customer
     // 2 - Do not allow checkout if faddress is invalid
     switch (Mage::getStoreConfig('rocketweb_addressvalidator/general/validation_type')) {
         // For Warn customer (1)
         case RocketWeb_UpsAddressTypeValidator_Helper_Addressvalidation::WARN_CUSTOMER:
             // Get whatever the shipping methods HTML is
             $shippingMethodsHtml = parent::_getShippingMethodsHtml();
             // If the controller is in the scope (frontend in this case)
             if ($helper->doValidateAddress()) {
                 // Load customer's shipping address
                 $shipping = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress();
                 // Get Address type
                 $ups_address_type = RocketWeb_UpsAddressTypeValidator_Helper_Data::getAddressTypeFromAddress($shipping);
                 // Check if the address is valid by calling UPS
                 $is_valid_address = is_numeric($ups_address_type) ? true : false;
                 // If UPS couldn't determine the address type and the country is US
                 if ($shipping->getCountryId() == 'US' && ($session->getData('invalid_address') || !$is_valid_address)) {
                     // Prepend the warning message to shipping methods HTML
                     $shippingMethodsHtml = '<strong>' . Mage::getStoreConfig('rocketweb_addressvalidator/general/customer_warning_message') . '</strong>' . $shippingMethodsHtml;
                 }
             }
             return $shippingMethodsHtml;
             break;
             // For Stopping the checkout (2)
         // For Stopping the checkout (2)
         case RocketWeb_UpsAddressTypeValidator_Helper_Addressvalidation::DISALLOW_CHECKOUT:
             // If the controller is in the scope (frontend in this case)
             if ($helper->doValidateAddress()) {
                 // Load customer's shipping address
                 $shipping = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress();
                 // Get Address type
                 $ups_address_type = RocketWeb_UpsAddressTypeValidator_Helper_Data::getAddressTypeFromAddress($shipping);
                 // Check if the address is valid by calling UPS
                 $is_valid_address = is_numeric($ups_address_type) ? true : false;
                 // Add type to session
                 $session->setVisitorData('ups_address_type', $ups_address_type);
                 // If the country is US and the address is invalid
                 if ($shipping->getCountryId() == 'US' && ($session->getData('invalid_address') || !$is_valid_address)) {
                     // Replace the actual shipping HTML opion with a message
                     $shippingMethodsHtml = '<strong>' . Mage::getStoreConfig('rocketweb_addressvalidator/general/checkout_stop_message') . '</strong>';
                     return $shippingMethodsHtml;
                 } else {
                     return parent::_getShippingMethodsHtml();
                 }
             } else {
                 return parent::_getShippingMethodsHtml();
             }
             break;
         case RocketWeb_UpsAddressTypeValidator_Helper_Addressvalidation::NO_VALIDATION:
             return parent::_getShippingMethodsHtml();
         default:
             return parent::_getShippingMethodsHtml();
     }
 }
示例#15
0
 /**
  * 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();
 }
示例#16
0
 /**
  * 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();
                     }
                 }
             }
         }
     }
 }