0

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.

1

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>

0

I have tried your code and found it working fine.

I think you may have put your code at a wrong place.

Please check it with the following checkout_cart_index.xml code and let me know if it helps:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <update handle="checkout_cart_item_renderers"/>
    <body>
        <move element="checkout.cart.coupon" destination="checkout.cart.totals.container" before="checkout.cart.totals" />
    </body>
</page>
  • hi @Mohit, Tried your code, that didn't move the coupon block. it is still same after cache flush also. – jafar pinjar Nov 14 '18 at 10:20
  • Remove the content of pub/static too. – Greg Nov 14 '18 at 10:33
  • Yes, did but no luck, its still in same place. – jafar pinjar Nov 14 '18 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.