I had the exact same problem. I bought a template for 1.7.2, not knowing I just installed version 1.8.1.
One of the things I had trouble with was this situation. The fix is not that hard.
In the app/design/frontend/default/[themename]/template/persistent/checkout/onepage/login.phtml
you will have to add a signle line.
Find <ul class="form-list">
and add:
<input type="hidden" name="form_key" value="<? echo Mage::getSingleton('core/session')->getFormKey(); ?>" />
I also had to do the same in app/design/frontend/default/[themename]/template/persistent/customer/form/login.phtml
.
First of all I want to say that this may be bad for business.
It's not a good idea to disable the button.
If you don't want guest users to be able to order just disable the guest checkout from System->Configuration->Checkout->Checkout Options->Allow Guest Checkout.
Then, the users will see the checkout page but they will be forced to login or create an account to perform the checkout process.
But if you insist here is how you can do it.
You can override the method: Mage_Checkout_Block_Onepage_Link::isDisabled
.
Add this in the config.xml
of one of your modules under the <global>
tag.
<blocks>
<checkout>
<rewrite>
<onepage_link>[Namespace]_[Module]_Block_Onepage_Link</onepage_link>
</rewrite>
</checkout>
</blocks>
Then create the file [Namespace]/[Module]/Block/Onepage/Link.php
with this content
<?php
class [Namespace]_[Module]_Block_Onepage_Link extends Mage_Checkout_Block_Onepage_Link {
public function isDisabled() {
if (parent::isDisabled()) {
return true;
}
return !Mage::getSingleton('customer/session')->isLoggedIn();
}
}
Now you have to make sure that only logged in customer can access the checkout page. Because if you only disable the button they will be able to use the direct link.
observe the event controller_action_predispatch_checkout_onepage_index
.
You can do that by adding this in the same config.xml as above inside the <frontend>
tag:
<events>
<controller_action_predispatch_checkout_onepage_index>
<observers>
<[namespace]_[module]>
<class>[Namespace]_[Module]_Model_Observer</class>
<method>checkCustomerLogin</method>
</[namespace]_[module]>
</observers>
</controller_action_predispatch_checkout_onepage_index>
</events>
And create the following file [Namespace]/[Module]/Model/Observer.php
:
<?php
class [Namespace]_[Module]_Model_Observer {
public function checkCustomerLogin() {
if(! Mage::helper('customer')->isLoggedIn()){
Mage::getSingleton('checkout/session')->addError(Mage::helper('checkout')->__('Only logged in customers can checkout'));
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('checkout/cart/'));
}
}
}
Best Answer
This problem is available due to you have keep cache disable in your site.
If you enable cache in your system, You dont ask for login again in popup box in cart page.
This is default bug in magento 2 when cache is disable at that time you have to ask for login again in cart page.
Still magento 2.1 version this bug is not solved by magento team.
This is listed in github issue list.
You can go directly checkout page using click on go to checkout button inside minicart at top or directly set checkout url in your browser.