0

While a user who is not logged in, clicks Proceed to checkout, I want them to be taken to the login page. Then, after they've logged in or registered, they should be taken back to the checkout page. in Magento-1 it's possible app/design/frontend/base/default/template/checkout/onepage.phtml.

<?php
          if (!$this->helper('customer')->isLoggedIn()) {
                 header("Location: /customer/account/login/");
                 exit();
          }
   ?>

how can I do same task in Magento2.

2

For your Requirement , Better Option is Disable Gust Order.

https://docs.magento.com/m2/ce/user_guide/sales/checkout-guest.html

By default, the guest checkout in Magento is enabled and visitors can place an order without registering to the website. Some websites require mandatory login for placing orders, and this default feature should be turned off to disallow guest checkout.

To disable guest checkout, navigate to:

System > Configuration > Sales section > Checkout > Checkout Options

Set Allow Guest Checkout to No

  • ok but get this message after configuring checkout options set to No. To check out, please sign in with your email address. – irshad Dec 11 '19 at 8:54
  • A Popup Appear having 2 options 1. Login exists customer 2. Create a new customer,it means you need an account to the website to order products – Shafeel Sha Dec 11 '19 at 8:57
  • only getting this one i.stack.imgur.com/StbUw.png. i need form sign-in/register. – irshad Dec 11 '19 at 9:22
  • prnt.sc/q983tb , this is i am testing with my testproject plaese follow this settings prnt.sc/q9844p .. this should work for you – Shafeel Sha Dec 11 '19 at 9:30
  • to enable onepage checkout follow Admin >> Store >> Configuration >> Sales >> Checkout >> Checkout Options >> Enable Onepage Checkout >> Yes. – Shafeel Sha Dec 11 '19 at 9:35

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.