I need some change in website. When product add to cart then page auto redirect to checkout page . Magento default option show only for auto redirect cart page but I need redirect to checkout page

  • You need to customize that section when adding product to cart. Aug 27, 2018 at 18:59
  • how to customize
    – user129727
    Aug 27, 2018 at 19:00
  • Are you using default add to cart action? Aug 27, 2018 at 19:00
  • @SukumarGorai yes
    – user129727
    Aug 27, 2018 at 19:01
  • use porto theme
    – user129727
    Aug 27, 2018 at 19:01

3 Answers 3



Override the above Class. Then you will find the addAction() method, in this method magento add products to cart so you can add your logics and change the redirect url to your custom url.


There are many ways to do this

When product add to cart then page auto redirect to checkout page

You can do this at the server side or at the client (browser side). To do it simply at the client, add a one-liner js at the top of this file:


<?php // place the following at the top of cart.phtml ?>
<script type="text/javascript">
window.location.replace('<?php echo $this->getUrl('checkout/onepage') ?>');

The above assume that you want to redirect to onepage checkout. But you can easily modify it to accommodate other checkout types.

To do it at the server side have many more possibilities depending on the exact requirements. For example, you can have a custom controller to handle the creation of the quote object. The same controller can then redirect to the checkout page. You can also listen to the event checkout_cart_add_product_complete and then set the redirect URL in your observer:

public function cartRedirect($observer)
    if (!Mage::getSingleton('checkout/session')->getQuote()->getHasError()) {
        $url = Mage::getUrl('checkout/onepage');
        $observer->getResponse()->setHeader('Location', $url);

Add product to cart then auto redirect to checkout page use magento event.

Create your custom module & Declare event observers in config.xml


Create your observers file in model . To redirect Magento to checkout use something similar in the Observer code:

class Vendor_Custommodule_Model_Observer 

    public function cartProductUpdateAfter($observer)

    public function cartProductAddAfter($observer)
        $response = $observer->getResponse();
        $url = Mage::helper('checkout/url')->getCheckoutUrl();

Your Answer

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

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