I am facing the issue with “Guest checkout is disabled” error after the customer log in using Ajax call. Guest checkout is disabled due to the requirement. The below code will run on clicking by the “go to checkout” button.
$objectManager = MagentoFrameworkAppObjectManager::getInstance(); $customer = $objectManager->create('MagentoCustomerModelCustomer')->load(3121); //2 is Customer ID $customerSession = $objectManager->create('MagentoCustomerModelSession'); $customerSession->setCustomerAsLoggedIn($customer);
After getting ajax response I am trying to redirect on the checkout but it redirects on the checkout/cart page with “Guest checkout is disabled”.
I have also set the section file for the ajax call and update the customer section.
If anyone has to face the issue please suggest the your thoughts.
Thanks in advanced.