When a user who is not logged in (anonymous) clicks Proceed to checkout
, I want them the be taken to the login page. Then, after they've logged in or registered, they should be taken back to the checkout page.
I'm using onepage checkout, which has a login section you're not logged in, but the powers that be don't want this.
Initially, I started down the route of changing checkout.xml
to have these values:
<customer_logged_in>
<block type="core/text_list" name="checkout.cart.top_methods" as="top_methods" translate="label">
<label>Payment Methods Before Checkout Button</label>
<block type="checkout/onepage_link" name="checkout.cart.methods.onepage" template="checkout/onepage/link.phtml"/>
</block>
</customer_logged_in>
<customer_logged_out>
<block type="core/text_list" name="checkout.cart.top_methods" as="top_methods" translate="label">
<label>Payment Methods Before Checkout Button</label>
<block type="checkout/onepage_link_not_logged_in" name="checkout.cart.methods.onepage" template="checkout/onepage/link_not_logged_in.phtml"/>
</block>
</customer_logged_out>
And link_not_logged_in.phtml
:
$this->getLoginUrl();
but this did not even pull my new phtml file, and I'm not even sure this would take me to the checkout page after. Any articles or help greatly receieved.
Go to your site's admin
. Click Stores
. Go to Configuration
-> Sales
-> Checkout
-> Checkout Options
and set Allow Guest Checkout
to "No"`
edit
Open app/design/frontend/base/default/template/checkout/onepage.phtml
. Place the following code at the very top of the file:
<?php
if (!$this->helper('customer')->isLoggedIn()) {
header("Location: /customer/account/login/");
exit();
}
?>
Finally, install Custom Login Redirect
at https://marketplace.magento.com/magehit-magehit-customloginredirect.html. Go to Admin -> System -> Configuration -> Customers -> Custom Login Redirect. Set it to checkout/cart
All set! I tested this and it does what you have described. Normally I would go through all of the various steps to complete the revisions that are present in these Extensions but you can see that by going to app/code/local and viewing the extension code.