I want to make a function in which only login user can see the proceed to checkout button at checkout page if non registered user will come at checkout page then they will see checkout button disabled
Magento – proceed to checkout button is only show for login users
checkoutmagento-1.8payment
Best Answer
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.Then create the file
[Namespace]/[Module]/Block/Onepage/Link.php
with this contentNow 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:And create the following file
[Namespace]/[Module]/Model/Observer.php
: