Magento – Apply discount Block moving issue in magento2 cart page

blocksmagento2shopping-cart

I need to move apply discount block to the summary block in cart page.

I have used below code in
Vendor/Module/view/frontend/layout/checkout_cart_index.xml

<move element="checkout.cart.coupon" 
destination="checkout.cart.totals.container" before="checkout.cart.totals" />

It is not moved to summary block.

Is there anything to achieve like that.

Best Answer

Try to check this solution. Add layout file with the following name

checkout_cart_index.xml

into your module and insert xml code like this for moving discount block

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceBlock name="checkout.cart.coupon" remove="true"/>
    <block class="Magento\Checkout\Block\Cart\Coupon" name="checkout.cart.coupon2" as="coupon" template="Magento_Checkout::cart/coupon.phtml"/>
    <move element="checkout.cart.coupon2" destination="cart.summary" after="checkout.cart.shipping"/>
</body>

Related Topic