In my custom module I have to check some conditions and have to disable "Proceed to Checkout" button from the Cart page.

I know it's coming from


I can override this but I have to also override block for this. Is there any other way to achieve this?

  • What exactly do you want to achieve here? Commented Aug 22, 2018 at 10:39

3 Answers 3


In your custom module or if you have a design template create view -> frontend -> templates -> onepage -> link.phtml and inside just put:


<?php if ($block->isPossibleOnepageCheckout()):?>

<?php endif?>

This should just not create the button.


You can try following code, here I have rewritten the template file in my custom module. app/code/Anshu/Custom/registration.php



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Anshu_Custom" setup_version="1.0.0">
            <module name="Magento_Checkout" />


<?xml version="1.0" encoding="UTF-8"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceContainer name="content">
            <referenceBlock name="checkout.cart.methods.onepage.bottom" template="Anshu_Custom::onepage/link.phtml" />


// @codingStandardsIgnoreFile
<?php if ($block->isPossibleOnepageCheckout()):?>
    <button type="button"
            title="<?= /* @escapeNotVerified */ __('Proceed to Checkout') ?>"
            data-mage-init='{"Magento_Checkout/js/proceed-to-checkout":{"checkoutUrl":"<?= /* @escapeNotVerified */ $block->getCheckoutUrl() ?>"}}'
            class="action primary checkout<?= ($block->isDisabled()) ? ' disabled' : '' ?>"
            <?php if ($block->isDisabled()):?>disabled="disabled"<?php endif; ?>>
        <span><?= /* @escapeNotVerified */ __('Proceed to Checkout') ?></span>
<?php endif?>

I have just copied the code from original core link.phtml file, you can modify it according to your requirement.

  • I am doing exact same thing that you mentioned above, added a code in custom block to check customer group data and disable button based on that check. In my case it disabled the button for all the customers including Guest. I tried cacheable=false in layout xml and it didn't fix it either. What kind of caching issue is it since the button is disabled even after bin/magento cache:flush?
    – cnu
    Commented Apr 4, 2019 at 17:02
  • @cnu The code is just for over ridding the template file, you need to apply the condition according to your requirement. Commented Apr 4, 2019 at 17:08
  • Right, I have the condition and it's working but the button disappears even when data is not there for the condition, so trying to understand if it's a caching or some other problem.
    – cnu
    Commented Apr 4, 2019 at 18:17
  • @cnu Doesn't seems to be cache issue, I am assuming it will be a condition issue. Kindly check your condition. Commented Apr 5, 2019 at 4:50
  • found the issue. It was a typo in one of the variable names in custom Block, hence the button was missing for every customer.
    – cnu
    Commented Apr 5, 2019 at 14:19

Override the helper function canOnepageCheckout. To achieve this you need to override the following class


Create your own module and add the following code to your di.xml

<?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\Helper\Data" type="Vendor\Module\Helper\Data" />

And update your logic to the below function:

public function canOnepageCheckout()
    return (bool)$this->scopeConfig->getValue('checkout/options/onepage_checkout_enabled', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);

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.