Hello,
Magento newbie here with a newbie question: what's the proper way to redirect user directly to checkout (i.e. skipping cart page) after "Add to cart" button is clicked on product page?
I'm using Magento 2.1.5.
This might help: http://magento.stackexchange.com/questions/138035/magento-2-skipping-shopping-cart-page-after-add-to...
Thanks for your answer!
I've at that topic earlier but actually it didn't really help too much. There are a few tips around but I just can't get this simple thing done. Do you know what's the event name that I'm supposed to be looking at? How do I even know where to look at such information? Some have suggested controller_action_postdispatch_checkout_cart_add and checkout_cart_add_product_complete. I've tried these in etc/frontend/events.xml
<event name="controller_action_postdispatch_checkout_cart_add"> <observer name="skip_shopping_cat_page" instance="Custom\Module\Observer\GoToCheckoutProduct" /> </event>
And consequently in Observer/GoToCheckoutProduct.php tried different things such as
namespace Custom\Module\Observer; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; class GoToCheckoutProduct implements ObserverInterface { protected $_url; public function execute(Observer $observer) { $redirect = $observer->getEvent()->getRedirect(); $redirect->setRedirect(true)->setPath('checkout')->setArguments([]); return $this; } }
But nothing seems to work...slightly frustrating. Any help would be greatly appreciated, thanks!