/**
  * Action predispatch
  *
  * Check customer authentication for some actions
  *
  * @return Mage_Checkout_MultishippingController
  */
 public function preDispatch()
 {
     parent::preDispatch();
     $action = $this->getRequest()->getActionName();
     if (!preg_match('#^(login|register)#', $action)) {
         if (!AO::getSingleton('customer/session')->authenticate($this, $this->_getHelper()->getMSLoginUrl())) {
             $this->setFlag('', self::FLAG_NO_DISPATCH, true);
         }
         if (!AO::helper('checkout')->isMultishippingCheckoutAvailable()) {
             $this->_redirectUrl($this->_getHelper()->getCartUrl());
             $this->setFlag('', self::FLAG_NO_DISPATCH, true);
             return $this;
         }
     }
     if (!$this->_preDispatchValidateCustomer()) {
         return $this;
     }
     if (AO::getSingleton('checkout/session')->getCartWasUpdated(true) && !in_array($action, array('index', 'login', 'register', 'addresses', 'success'))) {
         $this->_redirectUrl($this->_getHelper()->getCartUrl());
         $this->setFlag('', self::FLAG_NO_DISPATCH, true);
     }
     if ($action == 'success' && $this->_getCheckout()->getCheckoutSession()->getDisplaySuccess(true)) {
         return $this;
     }
     $quote = $this->_getCheckout()->getQuote();
     if (!$quote->hasItems() || $quote->getHasError() || $quote->isVirtual()) {
         $this->_redirectUrl($this->_getHelper()->getCartUrl());
         $this->setFlag('', self::FLAG_NO_DISPATCH, true);
         return;
     }
     return $this;
 }
Пример #2
0
 /**
  * Check if customer is logged in or not
  * If not logged in then redirect to customer login
  */
 public function preDispatch()
 {
     parent::preDispatch();
     if (!Mage::getSingleton('customer/session')->authenticate($this)) {
         $this->setFlag('', 'no-dispatch', true);
     }
 }
Пример #3
0
 /**
  * @return Mage_Checkout_OnepageController
  */
 public function preDispatch()
 {
     parent::preDispatch();
     if (!$this->_preDispatchValidateCustomer()) {
         return $this;
     }
     return $this;
 }
 /**
  * Pre dispatch hook. Remove addresses created by multishipping checkout
  *
  */
 public function preDispatch()
 {
     parent::preDispatch();
     $checkoutSessionQuote = Mage::getSingleton('checkout/session')->getQuote();
     if ($checkoutSessionQuote->getIsMultiShipping()) {
         $checkoutSessionQuote->setIsMultiShipping(false);
         $checkoutSessionQuote->removeAllAddresses();
     }
     return $this;
 }
 /**
  * @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->getRequest()->getActionName() != 'success') {
         Mage::helper('anattadesign_awesomecheckout')->estimateShipping();
     }
     return $this;
 }
 /**
  * Action predispatch
  *
  * Check customer authentication for some actions
  *
  * @return Mage_Checkout_MultishippingController
  */
 public function preDispatch()
 {
     parent::preDispatch();
     if ($this->getFlag('', 'redirectLogin')) {
         return $this;
     }
     $action = strtolower($this->getRequest()->getActionName());
     $checkoutSessionQuote = $this->_getCheckoutSession()->getQuote();
     /**
      * Catch index action call to set some flags before checkout/type_multishipping model initialization
      */
     if ($action == 'index') {
         $checkoutSessionQuote->setIsMultiShipping(true);
         $this->_getCheckoutSession()->setCheckoutState(Mage_Checkout_Model_Session::CHECKOUT_STATE_BEGIN);
     } elseif (!$checkoutSessionQuote->getIsMultiShipping() && !in_array($action, array('login', 'register', 'success'))) {
         $this->_redirect('*/*/index');
         $this->setFlag('', self::FLAG_NO_DISPATCH, true);
         return $this;
     }
     if (!in_array($action, array('login', 'register'))) {
         if (!Mage::getSingleton('customer/session')->authenticate($this, $this->_getHelper()->getMSLoginUrl())) {
             $this->setFlag('', self::FLAG_NO_DISPATCH, true);
         }
         if (!Mage::helper('checkout')->isMultishippingCheckoutAvailable()) {
             $error = $this->_getCheckout()->getMinimumAmountError();
             $this->_getCheckoutSession()->addError($error);
             $this->_redirectUrl($this->_getHelper()->getCartUrl());
             $this->setFlag('', self::FLAG_NO_DISPATCH, true);
             return $this;
         }
     }
     if (!$this->_preDispatchValidateCustomer()) {
         return $this;
     }
     if ($this->_getCheckoutSession()->getCartWasUpdated(true) && !in_array($action, array('index', 'login', 'register', 'addresses', 'success'))) {
         $this->_redirectUrl($this->_getHelper()->getCartUrl());
         $this->setFlag('', self::FLAG_NO_DISPATCH, true);
     }
     if ($action == 'success' && $this->_getCheckout()->getCheckoutSession()->getDisplaySuccess(true)) {
         return $this;
     }
     $quote = $this->_getCheckout()->getQuote();
     if (!$quote->hasItems() || $quote->getHasError() || $quote->isVirtual()) {
         $this->_redirectUrl($this->_getHelper()->getCartUrl());
         $this->setFlag('', self::FLAG_NO_DISPATCH, true);
         return;
     }
     return $this;
 }
Пример #7
0
 /**
  * @return Mage_Checkout_OnepageController
  */
 public function preDispatch()
 {
     parent::preDispatch();
     $this->_preDispatchValidateCustomer();
     $checkoutSessionQuote = Mage::getSingleton('buyback/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;
 }
 /**
  * Check query string paramters for order reference and/or access token
  */
 public function preDispatch()
 {
     parent::preDispatch();
     $this->_amazonOrderReferenceId = htmlentities($this->getRequest()->getParam('amazon_order_reference_id'));
     if (!$this->_amazonOrderReferenceId) {
         $this->_amazonOrderReferenceId = Mage::getSingleton('checkout/session')->getAmazonOrderReferenceId();
     } else {
         Mage::getSingleton('checkout/session')->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
     }
     // User is logging in...
     $token = htmlentities($this->getRequest()->getParam('access_token'));
     if ($token) {
         $_amazonLogin = Mage::getModel('amazon_login/customer');
         if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
             if (!$this->_getConfig()->isGuestCheckout() || !$this->_getOnepage()->getQuote()->isAllowedGuestCheckout()) {
                 $customer = $_amazonLogin->loginWithToken($token, $this->_checkoutUrl);
             } else {
                 $amazonProfile = $_amazonLogin->getAmazonProfile($token);
                 if ($amazonProfile && isset($amazonProfile['email'])) {
                     Mage::getSingleton('checkout/session')->setCustomerEmail($amazonProfile['email']);
                     Mage::getSingleton('checkout/session')->setCustomerName($amazonProfile['name']);
                 }
             }
         }
         Mage::getSingleton('checkout/session')->setAmazonAccessToken($token);
         // Full-page redirect (user did not sign in using popup)
         if ($this->getRequest()->getParam('nopopup')) {
             $this->_redirectUrl(Mage::helper('amazon_payments')->getCheckoutUrl(false) . '#access_token=' . $token);
         } else {
             if (Mage::app()->getRequest()->getParams('account') == 'redirect') {
                 $this->_redirect('customer/account');
             } else {
                 if (!$this->getRequest()->getParam('ajax')) {
                     $this->_redirect($this->_checkoutUrl, array('_secure' => true));
                     return;
                 }
             }
         }
     }
 }