0

I want to remove the 'Proceed to Checkout' button when the qty reaches a specified limit. For that I add a condition check in this page

module-checkout\view\frontend\templates\onepage\link.phtml

On qty update I have added an ajax call to the controller and passing the layouts as the ajax response and load the section. I am following the below link

How to Render an HTML Using an Ajax Call in Magento 2 Module

In my controller I have added the below code

$block = $resultPage->getLayout()
            ->createBlock('Magento\Checkout\Block\Cart')
            ->setTemplate('Magento_Checkout::cart/methods.phtml')
            ->toHtml();

The issue is that, the checkout button is not loading since it is a child of this block.

    <block class="Magento\Checkout\Block\Cart" name="checkout.cart.methods.bottom" template="Magento_Checkout::cart/methods.phtml">
        <container name="checkout.cart.methods" as="methods" label="Payment Methods After Checkout Button">
            <block class="Magento\Checkout\Block\Onepage\Link" name="checkout.cart.methods.onepage.bottom" template="Magento_Checkout::onepage/link.phtml" />
            <block class="Magento\Checkout\Block\QuoteShortcutButtons" name="checkout.cart.shortcut.buttons" />
        </container>
   </block>

Now, I need to render the child blocks along with this.

How can I do this?

1 Answer 1

0

How you are creating the new parent block, you will have to create the child blocks and embed them in the block you created:

checkout.cart.methods.bottom

You will do the same as you did for the child blocks, and then using the method addChild to include the child blocks in the parent.

I am pretty sure that there is a better way to achieve the requirements, maybe using knockout JS.

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.