I want to disable "guest checkout is disabled" warning on cart page. How can i this?

  • check and let me know it's working for you or not Commented Dec 15, 2019 at 8:06
  • I will try but it seems not ok.
    – cmbilisim
    Commented Dec 16, 2019 at 16:18
  • what you seems not ok? as you asked in question i have added notice on cart page. Commented Dec 16, 2019 at 16:33
  • By default the notice already show on cart page I want to turn off that notice.
    – cmbilisim
    Commented Dec 16, 2019 at 16:38
  • Ohh sorry i understood totally wrong. i checked but not getting any notice there Commented Dec 16, 2019 at 16:41

1 Answer 1


Create di.xml file under


and use the code below

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Checkout\Controller\Index\Index" type="Vendor\Module\Controller\Index\Index"/>

Create Index.php file under


and use the code below

namespace Vendor\Module\Controller\Index;

class Index extends \Magento\Checkout\Controller\Index\Index
    public function execute()
        /** @var \Magento\Checkout\Helper\Data $checkoutHelper */
        $checkoutHelper = $this->_objectManager->get(\Magento\Checkout\Helper\Data::class);
        if (!$checkoutHelper->canOnepageCheckout()) {
            $this->messageManager->addError(__('One-page checkout is turned off.'));
            return $this->resultRedirectFactory->create()->setPath('checkout/cart');

        $quote = $this->getOnepage()->getQuote();
        if (!$quote->hasItems() || $quote->getHasError() || !$quote->validateMinimumAmount()) {
            return $this->resultRedirectFactory->create()->setPath('checkout/cart');

        if (!$this->_customerSession->isLoggedIn() && !$checkoutHelper->isAllowedGuestCheckout($quote)) {
            // $this->messageManager->addError(__('Guest checkout is disabled.'));
            return $this->resultRedirectFactory->create()->setPath('checkout/cart');

        // generate session ID only if connection is unsecure according to issues in session_regenerate_id function.
        // @see http://php.net/manual/en/function.session-regenerate-id.php
        if (!$this->isSecureRequest()) {
        $resultPage = $this->resultPageFactory->create();
        return $resultPage;

     * Checks if current request uses SSL and referer also is secure.
     * @return bool
    private function isSecureRequest(): bool
        $request = $this->getRequest();

        $referrer = $request->getHeader('referer');
        $secure = false;

        if ($referrer) {
            $scheme = parse_url($referrer, PHP_URL_SCHEME);
            $secure = $scheme === 'https';

        return $secure && $request->isSecure();

Hope this will help you!

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.