문제

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.

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top