4

How do I disable guest checkout for recurring product in Magento. Its very strange that magento allows Guest Checkout for recurring products and it doesn't work.

1
  • 2
    we will disable guest checkout Admin->System->configuration->Sales->Checkout->Checkout options->Allow Guest Checkout -> (select no)
    – Vishal
    Sep 17, 2013 at 5:58

1 Answer 1

4

You can add an observer on this event checkout_allow_guest that goes something like this:

function checkAllowGuest($observer){
    $quote = $observer->getEvent()->getQuote();
    $result = $observer->getEvent()->getResult();
    foreach ($quote->getAllItems() as $item){
        if ($item->getProduct()->getIsRecurring()){//check if the product is recurring. Condition may be diffrent.
            $result->setIsAllowed(false); //don't allow checkout
            break;
        }
    }
}
1
  • How can I restrict guest user to purchase certain products in checkout. I have tried above solution and set if condition with product name but its not working.. Dec 5, 2018 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.