0

I want to disable the shopping cart page. I mean that when customers add products to cart, Magento will skip the shopping cart page and redirects them to the checkout page to shorten buying process.

Is there any way to make it successful?

Please suggest me.

2
  • 1
    magento verision?
    – Amit Bera
    May 8, 2016 at 12:56
  • Want the redirection for after cart or at any time if user hit checkout/cart/
    – Amit Bera
    May 8, 2016 at 13:19

2 Answers 2

0

My final observer:

I've added a check for cart items because if cart cookie expires or you refresh checkout or success order page, magento displays error 500, too many redirects. If there are no items in cart you must redirect to another page like homepage.

  public function forceCheckoutRedirect($observer){

  $numberOfItems = Mage::helper('checkout/cart')->getItemsCount();
  // force redirct to checkout page if cart is not empty
  if($numberOfItems > 0) {
    Mage::app()->getFrontController()->getResponse()
    ->setRedirect(Mage::getUrl('onepage'))
    ->sendResponse();
    exit();
  }
  else {
    Mage::app()->getFrontController()->getResponse()
    ->setRedirect(Mage::getUrl('/'))
    ->sendResponse();
    exit();

  }

}
0

Assume that you have using magento 1.x version

and assume that you does not want access checkout/cart/ at all time.

For this case you can use Magento Event/observer.

This is case use magento event controller_action_predispatch_checkout_cart_index

and from this event observer redirect to checkout/onepage/ page

  <global>
    <events>
      <controller_action_predispatch_checkout_cart_index>
        <observers>
          <redirect_to_checkout_from_cart>
            <type>singleton</type>
            <class>[ModuleNameSpace]_[ModuleName]_Model_Observer</class>
            <method>forceToGoCheckoutPage</method>
          </redirect_to_checkout_from_cart>
        </observers>
      </controller_action_predispatch_checkout_cart_index>    
    </events>
  </global>

Observer:

<?php
class ModuleNameSpace]_[ModuleName]_Model_Observer{
    public function forceToGoCheckoutPage($observer){
        // force redirect to the checkout page
          Mage::app()->getFrontController()->getResponse()
                ->setRedirect(Mage::getUrl('checkout/onepage'))
                ->sendResponse();
exit();

    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.