How to redirect the Checkout button to Checkout

How to redirect the customer to Checkout when he adds 1 item to the cart by skipping the Cart page.

For this tutorial you should already have the structure of a Magento module ready.

Function in Observer

public function addToCartComplete (Varien_Event_Observer $ observer) {// Send the user to the Item added page $ response = $ observer-> getResponse (); $ request = $ observer-> getRequest (); $ response-> setRedirect (Mage :: getUrl ('checkout / onepage')); Mage :: getSingleton ('checkout / session') -> setNoCartRedirect (true); }

Watching the Event

In the file config.xml of your module add in the section of events:

<events> <checkout_cart_add_product_complete> <observers> <zz_zzcore_addtocartcomplete> <class> Zz_Zzcore_Model_Observer </ method> addToCartComplete </ method> </ zz_zzcore_addtocartcomplete> </ observers> </ checkout_cart_add_product_complete> </ events>

Make the necessary changes in the lines:

<zz_zzcore_addtocartcomplete>

Also change the class name with the correct Model path within your module.

Zz_Zzcore_Model_Observer

After any changes to the Module do not forget to empty the Magento Cache before testing.

Rate This Article!

Click on the stars to give a note of 1 to 5.

1 star2 stars3 stars4 stars5 stars (No Ratings Yet)
Loading ...

Doubts? Make a comment below or send us a message by clicking here.

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