{"id":504,"date":"2019-07-12T11:30:18","date_gmt":"2019-07-12T11:30:18","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2019\/07\/12\/redirect-customer-login-or-registration-success-to-checkout-in-magento-2\/"},"modified":"2025-05-22T16:21:06","modified_gmt":"2025-05-22T10:51:06","slug":"redirect-customer-login-or-registration-success-to-checkout-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/redirect-customer-login-or-registration-success-to-checkout-in-magento-2\/","title":{"rendered":"How to Redirect Customer Login or Registration Success to Checkout in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Magento 2, by default, offers many features that help store owners to increase conversions. However, sometimes the default Magento 2 lacks functions that might just be helpful for that little push required for customers to convert!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To overcome such limitations, developers can tweak the default features to enhance the user experience, one which I discussed earlier to change the default configuration to&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/redirect-customers-to-previous-page-after-login-in-magento\/\">redirect customers to the previous page after login in Magento and Magento 2<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Similarly, I have implemented a solution to&nbsp;<em><strong>redirect customer login or registration success to checkout in Magento 2<\/strong><\/em>. However, you\u2019ll have to follow the programmatic method to do so.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also you can&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/redirect-customer-to-custom-page-after-login-in-magento-2\/\">redirect customer to custom page after login in Magento 2<\/a>&nbsp;as when a customer logs in to your store, it is the prime time when you can redirect their attention to things you want. It is a short time span where you can lure them for engagement or even conversion.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With this solution, the guest visitors who have selected items and added them to cart won\u2019t have to repeat the process after logging in or registering in your store! You can simply take them to the checkout step and encourage them to buy the items already added to the cart.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps to Redirect Customer Login or Registration Success to Checkout in Magento 2:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">1. Create&nbsp;<strong>di.xml<\/strong>&nbsp;file at&nbsp;<em><strong>app\/code\/Vendor\/Extension\/etc\/&nbsp;<\/strong><\/em>folder<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\"?>\n&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:ObjectManager\/etc\/config.xsd\">\n    &lt;type name=\"Magento\\Checkout\\Model\\Session\">\n        &lt;plugin name=\"set_redirection_url_if_have_quote\" type=\"Vendor\\Extension\\Plugin\\LoginRedirection\" \/>\n    &lt;\/type>\n&lt;\/config><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2. Create&nbsp;<strong>LoginRedirection<\/strong>&nbsp;file at&nbsp;<em><strong>app\/code\/Vendor\/Extension\/Plugin\/&nbsp;<\/strong><\/em>folder<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\nnamespace Vendor\\Extension\\Plugin;\n\nclass LoginRedirection\n{\n    protected $storeManager;\n    protected $customerSession;\n\n    public function __construct(\n        \\Magento\\Store\\Model\\StoreManagerInterface $storeManager,\n        \\Magento\\Customer\\Model\\Session $customerSession\n    )\n    {\n        $this->storeManager = $storeManager;\n        $this->customerSession = $customerSession;\n    }\n    public function afterLoadCustomerQuote(\n        \\Magento\\Checkout\\Model\\Session $subject,\n        $result\n    )\n    {\n        $quote = $subject->getQuote();\n        if(count($quote->getAllItems())>0){\n            $this->customerSession\n                ->setBeforeAuthUrl($this->storeManager->getStore()->getUrl('onepagecheckout\/index\/index'));\n        }\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Take your newly signed up customers directly to checkout, prompt them to make a purchase, and enjoy sales!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Magento 2, by default, offers many features that help store owners to increase conversions. However, sometimes the default Magento 2 lacks functions that might just&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-504","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/504","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=504"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/504\/revisions"}],"predecessor-version":[{"id":15346,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/504\/revisions\/15346"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}