Free Magento Redirect Cart to Checkout Page

Magento Redirect To Checkout After Adding To Cart: An Easy How-To Guide

“How to set up a quick buying process for customers to increase conversion rates and reduce abandoned rate”  is always an issue mostly store owners take much concern.

When customers add products to their cart by clicking “Add to Cart”,  they will be redirected to the shopping cart page to view their selected products. Actually there’s an option by Magento default for admins to choose sending the user to the cart or leaving them on the page. However, this step takes time and there is also a list of chosen items displayed in the checkout page.

Therefore, to save time for customers, some shop owners consider skipping the shopping cart page and directly moving customers to the checkout page. This make customers buy products faster without waiting for loading the shopping cart page which can cause them to abandon their carts.

alt=“abandoned-cart”

In this blog posts, we will introduce you (especially administrators of online stores and developers) the way we can disable the shopping cart page to improve the buying process in your site.

Create Magento redirect to checkout by using Event observer method

After products are added to carts,  it is a default process that the site will redirect to the shopping cart page. So how to disable loading the shopping cart page and redirect  to checkout page  after “Add to cart” even when they access intentionally to the URL of the shopping cart?

The easiest way is using the event observer method. It means that you take "controller_action_predispatch_checkout_cart_index" event to redirect 301 from the cart page to the checkout page. This is the “fired” event before loading "checkout_cart_index" page.

This following code is added to the declaration of event observer in the configuration file:

frontend>
<events>
 <controller_action_predispatch_checkout_cart_index>
 <observers>
<customRedir>
<class>disablecart/observer</class>
 <method>disableCart</method>
 </customRedir>
</observers>
</controller_action_predispatch_checkout_cart_index>
</events>
</frontend>

Enable or disable module

You may want to enable or disable module in some cases, so you can add a Store Config in the backend to easily use. You create the config/system.xml file:

<?xml version="1.0"?>
<config>
<sections>
<gotocheckout  translate="label" module="disablecart">                    
<label>Redirect Cart To Checkout</label>
<tab>general</tab>
<frontend_type>text</frontend_type>
<sort_order>0</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>        
<groups>
<general translate="label">
<label>General</label>
<frontend_type>text</frontend_type>
<sort_order>0</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<enable translate="label">
<label>Enable</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>0</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</enable>
</fields>
</general>
</groups>
</gotocheckout>
</sections>
</config>

Results

After finishing these code, you can see “Redirect Cart To Checkout” in the Configuration and then you can choose Yes or No to enable or disable it.

alt=“redirect-cart-to-checkout”

In the Model/Observer.php file, we declare disableCart

   public function disableCart(Varien_Event_Observer $observer){
   $storeId = Mage::app()->getStore()->getId();
   if(Mage::getStoreConfig('gotocheckout/general/enable', $storeId)){
    $controller = $observer->getControllerAction();
    $controller->getResponse()
    ->setRedirect(Mage::getUrl('checkout/onepage'),301)
    ->sendResponse();
     }
     return;
     }

Tips: If the website uses the One Step Check Out module, it may have to redirect to the other URL of the checkout: ->setRedirect(Mage::getUrl('onestepcheckout’),301)

Finally, when you finish the setup, you need to clear out cache and reload the page to test.

If you do not want to take much time for carrying out these things, you can easily get the full functions by downloading the full version of the Disable cart module [DOWNLOAD HERE]Our module will provide you all functions without any efforts.

If our blog has brought you helpful knowledge, please Like and Subscribe to our blog to get the latest shares for your Magento site.

Leave a Reply