Bypass cart and go to checkout

Sometimes there is a need to bypass the Magento shopping cart and go straight to checkout. Maybe your products (or services) are such that most customers only buy one product so why not speed up checkout by bypassing the cart.

Although Magento has an option in admin of whether to stay on product page or go to the shopping cart when you add a product to the cart, it does not handle bypass the shopping cart completely.

For this solution we will be creating a custom extension called Cart in the MCorner namespace. We will use Magento’s Event-Observer methodology to trigger a redirect to the checkout page. So let’s get started.

If you prefer, you can download this extension here.

Create the file app/etc/modules/MCorner_Cart.xml to enable the module.

<?xml version="1.0"?>

Now create the following directory path app/code/community/MCorner/Cart/etc.
Create the file config.xml with the following in it. This listens to the checkout_cart_add_product_complete event and calls our observer.

<?xml version="1.0"?>

Create the following directory path: app/code/community/MCorner/Cart/Model.
Now create a file Observer.php in the Model directory with the following:


class MCorner_Cart_Model_Observer extends Varien_Object
    public function afterAddToCart(Varien_Event_Observer $observer) {
        $response = $observer->getResponse();


The above code is our observer that triggers the redirect.
Now clear the cache and test adding a product to the cart.

Let us know your thoughts below.

15 thoughts on “Bypass cart and go to checkout

  1. Is there a way to trigger this cart bypass for a additional “add to cart” button?
    It would be great to have one button for default “add to cart” and one button for “direct checkout”.

    • Hi Jonas,

      It should not be too difficult, all you need to do is add an additional parameter to the add to cart url.

      and the code from Observer.php above replace with:

      < ?php class MCorner_Cart_Model_Observer extends Varien_Object { public function afterAddToCart(Varien_Event_Observer $observer) { if (Mage::app()->getRequest()->getParam(‘checkout’)) {
      $response = $observer->getResponse();

      There is an additional “if” statement that detects if there is that additional parameter and if there is such, it does redirect the client to the checkout page. So, all products not using that type of add to cart link will not get redirected to checkout.To have a product add button that redirects to checkout, add additional parameter to the add to cart url “/checkout”.

      Following the same logic, you can do it the other way around – special attribute stops redirect instead of activating one.

      I hope this helps.

      • Hi Stevo,

        Great function. Do you know a way to add more than one product at a time?


      • Hi Jesper,
        This intercepts adding a product in the cart and then redirects to checkout. So unfortunately this is triggered when adding a product to cart. You could possibly add multiple products at the same time (and this functionality should still work) but this is out of the scope of this article.

  2. Stevo,

    if (Mage::app()->getRequest()->getParam(‘checkout’)) {

    I added the above line in the Observer.php file but it does not seem to work. Everything works well without that line but I need the same functionality as Jonas does.

    Any pointers?

  3. Hi. Seems to work great when cache is disabled. When I activate the cache it is not working anymore. Any idea why?


    • Hi Daniel,
      Can you confirm that you have cleared cache. You may have old cache data that is being read. Cache is in you Magento directory var/cache/
      You can remove that manually.

      • Hello Sarg.

        Yep, I can confirm that I deleted the cache. I just tried another time just-in-case, but the shopping cart page still appear when I activate cache in the system.

        Do you have any other suggestions what I can check?

        / Daniel

  4. Daniel,
    Confirm all the code has been added correctly. Maybe you have another extension that interferes with this. You can try adding a var_dump() and exit in the afterAddToCart function. Clear cache and try again. If it dumps and exits it is getting to the function and you can investigate that. If not, you have an error elsewhere. Look at your apache logs too.

Leave a Reply

Your email address will not be published. Required fields are marked *