2

I have BuyNow button on my product page when I clicked on button it should redirect to checkout page and product should be added to cart page, please tell me proper solution over this how to do this.

4

Swash_nam, Goto cartcontroller (app>code>core>Mage>Checkout>controllers>CartController.php)'s function goback

$this->_redirect('checkout/cart');

Go to Admin>Configuration>Sales>Checkout>Shopping Cart>After Adding a Product Redirect to Shopping Cart and make it yes

|improve this answer|||||
  • Unless I am missing something in the question as @Amit shows above this is just a setting. – joesk Sep 16 '16 at 16:05
2

If anyone suggest that you should make changes to core code, ignore it! Making changes to core files is a Bad Thing and every Magento developer worth its salt avoids it at all costs.

That being said there's number of ways to achieve it. I would use observers. There's an excellent tutorial from Inchoo about building an observer extension which deal with something similar. I'm not :

http://inchoo.net/ecommerce/magento/tracking-magento-add-product-to-cart-action-for-analytic-software-purpose/

However, instead of controller_action_predispatch_checkout_cart_add, I would add_to_cart_after event.

Check also this article for the additional information:

http://inchoo.net/ecommerce/magento/dispatching-before-and-after-events-to-magento-core-actions/

To redirect Magento to checkout use something similar in the Observer code:

$response = $observer->getResponse();
$url = Mage::helper('checkout/url')->getCheckoutUrl();
$response->setRedirect($url);
|improve this answer|||||
0

Please check the answer form this post https://stackoverflow.com/a/4053248/3018289

Here is a copy for quick access.

You could create an observer listening for the checkout_cart_add_product_complete event and in there you could do something like the following

  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);
}

Your config would look something like this

 <frontend>
    <events>
    <checkout_cart_add_product_complete>
      <observers>
        <packagename_modulename_observer>
          <type>singleton</type>
          <class>packagename_modulename/observer</class>
          <method>addToCartComplete</method>
        </packagename_modulename_observer>
      </observers>
      </checkout_cart_add_product_complete>
   </events>
   </frontend>
|improve this answer|||||
0

There is a good tutorial to tell about how to create a module to make redirect cart to checkout more simple: https://bsscommerce.com/blog/magento-redirect-to-checkout-after-adding-to-cart-an-easy-how-to-guide/

I see that it give a detaied instruction aboutcreating a module by using envent Observer method the use config co control redirect cart to checkout

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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