Mage_Checkout_MultishippingController Class Reference

Inheritance diagram for Mage_Checkout_MultishippingController:

Mage_Checkout_Controller_Action Mage_Core_Controller_Front_Action Mage_Core_Controller_Varien_Action

List of all members.

Public Member Functions

 preDispatch ()
 indexAction ()
 loginAction ()
 registerAction ()
 addressesAction ()
 addressesPostAction ()
 backToAddressesAction ()
 removeItemAction ()
 shippingAction ()
 backToShippingAction ()
 shippingPostAction ()
 billingAction ()
 backToBillingAction ()
 overviewAction ()
 overviewPostAction ()
 successAction ()

Protected Member Functions

 _getCheckout ()
 _getState ()
 _getHelper ()
 _validateMinimumAmount ()
 _validateBilling ()


Detailed Description

Multishipping checkout controller

Author:
Magento Core Team <core@magentocommerce.com>

Definition at line 32 of file MultishippingController.php.


Member Function Documentation

_getCheckout (  )  [protected]

Retrieve checkout model

Returns:
Mage_Checkout_Model_Type_Multishipping

Definition at line 39 of file MultishippingController.php.

00040     {
00041         return Mage::getSingleton('checkout/type_multishipping');
00042     }

_getHelper (  )  [protected]

Retrieve checkout url heler

Returns:
Mage_Checkout_Helper_Url

Definition at line 59 of file MultishippingController.php.

00060     {
00061         return Mage::helper('checkout/url');
00062     }

_getState (  )  [protected]

Retrieve checkout state model

Returns:
Mage_Checkout_Model_Type_Multishipping_State

Definition at line 49 of file MultishippingController.php.

00050     {
00051         return Mage::getSingleton('checkout/type_multishipping_state');
00052     }

_validateBilling (  )  [protected]

Validation of selecting of billing address

Returns:
boolean

Definition at line 373 of file MultishippingController.php.

00374     {
00375         if(!$this->_getCheckout()->getQuote()->getBillingAddress()->getFirstname()) {
00376             $this->_redirect('*/multishipping_address/selectBilling');
00377             return false;
00378         }
00379         return true;
00380     }

_validateMinimumAmount (  )  [protected]

Definition at line 252 of file MultishippingController.php.

00253     {
00254         if (!$this->_getCheckout()->validateMinimumAmount()) {
00255             $error = $this->_getCheckout()->getMinimumAmountError();
00256             $this->_getCheckout()->getCheckoutSession()->addError($error);
00257             $this->_forward('backToAddresses');
00258             return false;
00259         }
00260         return true;
00261     }

addressesAction (  ) 

Multishipping checkout select address page

Definition at line 169 of file MultishippingController.php.

00170     {
00171         // If customer do not have addresses
00172         if (!$this->_getCheckout()->getCustomerDefaultShippingAddress()) {
00173             $this->_redirect('*/multishipping_address/newShipping');
00174             return;
00175         }
00176         $this->_getState()->setActiveStep(
00177             Mage_Checkout_Model_Type_Multishipping_State::STEP_SELECT_ADDRESSES
00178         );
00179         if (!$this->_getCheckout()->validateMinimumAmount()) {
00180             $message = $this->_getCheckout()->getMinimumAmountDescription();
00181             $this->_getCheckout()->getCheckoutSession()->addNotice($message);
00182         }
00183         $this->loadLayout();
00184         $this->_initLayoutMessages('customer/session');
00185         $this->_initLayoutMessages('checkout/session');
00186         $this->renderLayout();
00187     }

addressesPostAction (  ) 

Multishipping checkout process posted addresses

Definition at line 192 of file MultishippingController.php.

00193     {
00194         try {
00195             if ($this->getRequest()->getParam('continue', false)) {
00196                 $this->_getCheckout()->setCollectRatesFlag(true);
00197                 $this->_getState()->setActiveStep(
00198                     Mage_Checkout_Model_Type_Multishipping_State::STEP_SHIPPING
00199                 );
00200                 $this->_getState()->setCompleteStep(
00201                     Mage_Checkout_Model_Type_Multishipping_State::STEP_SELECT_ADDRESSES
00202                 );
00203                 $this->_redirect('*/*/shipping');
00204             }
00205             elseif ($this->getRequest()->getParam('new_address')) {
00206                 $this->_redirect('*/multishipping_address/newShipping');
00207             }
00208             else {
00209                 $this->_redirect('*/*/addresses');
00210             }
00211             if ($shipToInfo = $this->getRequest()->getPost('ship')) {
00212                 $this->_getCheckout()->setShippingItemsInformation($shipToInfo);
00213             }
00214         }
00215         catch (Mage_Core_Exception $e) {
00216             Mage::getSingleton('checkout/session')->addError($e->getMessage());
00217             $this->_redirect('*/*/addresses');
00218         }
00219         catch (Exception $e) {
00220             Mage::getSingleton('checkout/session')->addException(
00221                 $e,
00222                 Mage::helper('checkout')->__('Data saving problem')
00223             );
00224             $this->_redirect('*/*/addresses');
00225         }
00226     }

backToAddressesAction (  ) 

Definition at line 228 of file MultishippingController.php.

00229     {
00230         $this->_getState()->setActiveStep(
00231             Mage_Checkout_Model_Type_Multishipping_State::STEP_SELECT_ADDRESSES
00232         );
00233         $this->_getState()->unsCompleteStep(
00234             Mage_Checkout_Model_Type_Multishipping_State::STEP_SHIPPING
00235         );
00236         $this->_redirect('*/*/addresses');
00237     }

backToBillingAction (  ) 

Definition at line 382 of file MultishippingController.php.

00383     {
00384         $this->_getState()->setActiveStep(
00385             Mage_Checkout_Model_Type_Multishipping_State::STEP_BILLING
00386         );
00387         $this->_getState()->unsCompleteStep(
00388             Mage_Checkout_Model_Type_Multishipping_State::STEP_OVERVIEW
00389         );
00390         $this->_redirect('*/*/billing');
00391     }

backToShippingAction (  ) 

Definition at line 286 of file MultishippingController.php.

00287     {
00288         $this->_getState()->setActiveStep(
00289             Mage_Checkout_Model_Type_Multishipping_State::STEP_SHIPPING
00290         );
00291         $this->_getState()->unsCompleteStep(
00292             Mage_Checkout_Model_Type_Multishipping_State::STEP_BILLING
00293         );
00294         $this->_redirect('*/*/shipping');
00295     }

billingAction (  ) 

Multishipping checkout billing information page

Definition at line 323 of file MultishippingController.php.

00324     {
00325         if (!$this->_validateBilling()) {
00326             return;
00327         }
00328 
00329         if (!$this->_validateMinimumAmount()) {
00330             return;
00331         }
00332 
00333         if (!$this->_getState()->getCompleteStep(Mage_Checkout_Model_Type_Multishipping_State::STEP_SHIPPING)) {
00334             $this->_redirect('*/*/shipping');
00335             return $this;
00336         }
00337 
00338         $this->_getState()->setActiveStep(
00339             Mage_Checkout_Model_Type_Multishipping_State::STEP_BILLING
00340         );
00341 
00342         $this->loadLayout();
00343         $this->_initLayoutMessages('customer/session');
00344         $this->_initLayoutMessages('checkout/session');
00345         $this->renderLayout();
00346     }

indexAction (  ) 

Index action of Multishipping checkout

Definition at line 114 of file MultishippingController.php.

00115     {
00116         Mage::getSingleton('checkout/session')->setCartWasUpdated(false);
00117         $this->_getCheckout()->getCheckoutSession()->setCheckoutState(
00118             Mage_Checkout_Model_Session::CHECKOUT_STATE_BEGIN
00119         );
00120         $this->_redirect('*/*/addresses');
00121     }

loginAction (  ) 

Multishipping checkout login page

Definition at line 126 of file MultishippingController.php.

00127     {
00128         if (Mage::getSingleton('customer/session')->isLoggedIn()) {
00129             $this->_redirect('*/*/');
00130             return;
00131         }
00132 
00133         $this->loadLayout();
00134         $this->_initLayoutMessages('customer/session');
00135 
00136         // set account create url
00137         if ($loginForm = $this->getLayout()->getBlock('customer_form_login')) {
00138             $loginForm->setCreateAccountUrl($this->_getHelper()->getMSRegisterUrl());
00139         }
00140         $this->renderLayout();
00141     }

overviewAction (  ) 

Multishipping checkout place order page

Definition at line 396 of file MultishippingController.php.

00397     {
00398         if (!$this->_validateMinimumAmount()) {
00399             return $this;
00400         }
00401 
00402         $this->_getState()->setActiveStep(Mage_Checkout_Model_Type_Multishipping_State::STEP_OVERVIEW);
00403 
00404         try {
00405             $payment = $this->getRequest()->getPost('payment');
00406             $this->_getCheckout()->setPaymentMethod($payment);
00407             $this->_getCheckout()->getQuote()->getPayment()->importData($payment);
00408 
00409             $this->_getState()->setCompleteStep(
00410                 Mage_Checkout_Model_Type_Multishipping_State::STEP_BILLING
00411             );
00412 
00413             $this->loadLayout();
00414             $this->_initLayoutMessages('checkout/session');
00415             $this->_initLayoutMessages('customer/session');
00416             $this->renderLayout();
00417         }
00418         catch (Mage_Core_Exception $e) {
00419             Mage::getSingleton('checkout/session')->addError($e->getMessage());
00420             $this->_redirect('*/*/billing');
00421         }
00422         catch (Exception $e) {
00423             Mage::logException($e);
00424             Mage::getSingleton('checkout/session')->addException($e, $this->__('Can\'t open overview page'));
00425             $this->_redirect('*/*/billing');
00426         }
00427     }

overviewPostAction (  ) 

Definition at line 429 of file MultishippingController.php.

00430     {
00431         if (!$this->_validateMinimumAmount()) {
00432             return;
00433         }
00434 
00435         try {
00436             if ($requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds()) {
00437                 $postedAgreements = array_keys($this->getRequest()->getPost('agreement', array()));
00438                 if ($diff = array_diff($requiredAgreements, $postedAgreements)) {
00439                     Mage::getSingleton('checkout/session')->addError($this->__('Please agree to all Terms and Conditions before placing the order.'));
00440                     $this->_redirect('*/*/billing');
00441                     return;
00442                 }
00443             }
00444 
00445             $payment = $this->getRequest()->getPost('payment');
00446             $paymentInstance = $this->_getCheckout()->getQuote()->getPayment();
00447             if (isset($payment['cc_number'])) {
00448                 $paymentInstance->setCcNumber($payment['cc_number']);
00449             }
00450             if (isset($payment['cc_cid'])) {
00451                 $paymentInstance->setCcCid($payment['cc_cid']);
00452             }
00453             $this->_getCheckout()->createOrders();
00454             $this->_getState()->setActiveStep(
00455                 Mage_Checkout_Model_Type_Multishipping_State::STEP_SUCCESS
00456             );
00457             $this->_getState()->setCompleteStep(
00458                 Mage_Checkout_Model_Type_Multishipping_State::STEP_OVERVIEW
00459             );
00460             $this->_getCheckout()->getCheckoutSession()->clear();
00461             $this->_getCheckout()->getCheckoutSession()->setDisplaySuccess(true);
00462             $this->_redirect('*/*/success');
00463         }
00464         catch (Mage_Core_Exception $e){
00465             Mage::helper('checkout')->sendPaymentFailedEmail($this->_getCheckout()->getQuote(), $e->getMessage(), 'multi-shipping');
00466             Mage::getSingleton('checkout/session')->addError($e->getMessage());
00467             $this->_redirect('*/*/billing');
00468         }
00469         catch (Exception $e){
00470             Mage::helper('checkout')->sendPaymentFailedEmail($this->_getCheckout()->getQuote(), $e->getMessage(), 'multi-shipping');
00471             Mage::getSingleton('checkout/session')->addError('Order place error.');
00472             $this->_redirect('*/*/billing');
00473         }
00474     }

preDispatch (  ) 

Action predispatch

Check customer authentication for some actions

Returns:
Mage_Checkout_MultishippingController

Reimplemented from Mage_Core_Controller_Front_Action.

Definition at line 71 of file MultishippingController.php.

00072     {
00073         parent::preDispatch();
00074 
00075         $action = $this->getRequest()->getActionName();
00076         if (!preg_match('#^(login|register)#', $action)) {
00077             if (!Mage::getSingleton('customer/session')->authenticate($this, $this->_getHelper()->getMSLoginUrl())) {
00078                 $this->setFlag('', self::FLAG_NO_DISPATCH, true);
00079             }
00080 
00081             if (!Mage::helper('checkout')->isMultishippingCheckoutAvailable()) {
00082                 $this->_redirectUrl($this->_getHelper()->getCartUrl());
00083                 $this->setFlag('', self::FLAG_NO_DISPATCH, true);
00084                 return $this;
00085             }
00086         }
00087 
00088         if (!$this->_preDispatchValidateCustomer()) {
00089             return $this;
00090         }
00091 
00092         if (Mage::getSingleton('checkout/session')->getCartWasUpdated(true)
00093             && !in_array($action, array('index', 'login', 'register', 'addresses', 'success'))) {
00094             $this->_redirectUrl($this->_getHelper()->getCartUrl());
00095             $this->setFlag('', self::FLAG_NO_DISPATCH, true);
00096         }
00097 
00098         if ($action == 'success' && $this->_getCheckout()->getCheckoutSession()->getDisplaySuccess(true)) {
00099             return $this;
00100         }
00101 
00102         $quote = $this->_getCheckout()->getQuote();
00103         if (!$quote->hasItems() || $quote->getHasError() || $quote->isVirtual()) {
00104             $this->_redirectUrl($this->_getHelper()->getCartUrl());
00105             $this->setFlag('', self::FLAG_NO_DISPATCH, true);
00106             return;
00107         }
00108         return $this;
00109     }

registerAction (  ) 

Multishipping checkout login page

Definition at line 146 of file MultishippingController.php.

00147     {
00148         if (Mage::getSingleton('customer/session')->isLoggedIn()) {
00149             $this->_redirectUrl($this->_getHelper()->getMSCheckoutUrl());
00150             return;
00151         }
00152 
00153         $this->loadLayout();
00154         $this->_initLayoutMessages('customer/session');
00155 
00156         if ($registerForm = $this->getLayout()->getBlock('customer_form_register')) {
00157             $registerForm->setShowAddressFields(true)
00158                 ->setBackUrl($this->_getHelper()->getMSLoginUrl())
00159                 ->setSuccessUrl($this->_getHelper()->getMSShippingAddressSavedUrl())
00160                 ->setErrorUrl($this->_getHelper()->getCurrentUrl());
00161         }
00162 
00163         $this->renderLayout();
00164     }

removeItemAction (  ) 

Multishipping checkout remove item action

Definition at line 242 of file MultishippingController.php.

00243     {
00244         $itemId     = $this->getRequest()->getParam('id');
00245         $addressId  = $this->getRequest()->getParam('address');
00246         if ($addressId && $itemId) {
00247             $this->_getCheckout()->removeAddressItem($addressId, $itemId);
00248         }
00249         $this->_redirect('*/*/addresses');
00250     }

shippingAction (  ) 

Multishipping checkout shipping information page

Definition at line 266 of file MultishippingController.php.

00267     {
00268         if (!$this->_validateMinimumAmount()) {
00269             return;
00270         }
00271 
00272         if (!$this->_getState()->getCompleteStep(Mage_Checkout_Model_Type_Multishipping_State::STEP_SELECT_ADDRESSES)) {
00273             $this->_redirect('*/*/addresses');
00274             return $this;
00275         }
00276 
00277         $this->_getState()->setActiveStep(
00278             Mage_Checkout_Model_Type_Multishipping_State::STEP_SHIPPING
00279         );
00280         $this->loadLayout();
00281         $this->_initLayoutMessages('customer/session');
00282         $this->_initLayoutMessages('checkout/session');
00283         $this->renderLayout();
00284     }

shippingPostAction (  ) 

Definition at line 297 of file MultishippingController.php.

00298     {
00299         $shippingMethods = $this->getRequest()->getPost('shipping_method');
00300         try {
00301             Mage::dispatchEvent(
00302                 'checkout_controller_multishipping_shipping_post',
00303                 array('request'=>$this->getRequest(), 'quote'=>$this->_getCheckout()->getQuote())
00304             );
00305             $this->_getCheckout()->setShippingMethods($shippingMethods);
00306             $this->_getState()->setActiveStep(
00307                 Mage_Checkout_Model_Type_Multishipping_State::STEP_BILLING
00308             );
00309             $this->_getState()->setCompleteStep(
00310                 Mage_Checkout_Model_Type_Multishipping_State::STEP_SHIPPING
00311             );
00312             $this->_redirect('*/*/billing');
00313         }
00314         catch (Exception $e){
00315             Mage::getSingleton('checkout/session')->addError($e->getMessage());
00316             $this->_redirect('*/*/shipping');
00317         }
00318     }

successAction (  ) 

Multishipping checkout succes page

Definition at line 479 of file MultishippingController.php.

00480     {
00481         if (!$this->_getState()->getCompleteStep(Mage_Checkout_Model_Type_Multishipping_State::STEP_OVERVIEW)) {
00482             $this->_redirect('*/*/addresses');
00483             return $this;
00484         }
00485 
00486         $this->loadLayout();
00487         $this->_initLayoutMessages('checkout/session');
00488         $this->renderLayout();
00489     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:52 2009 for Magento by  doxygen 1.5.8