How to Move Apply Coupon to Sidebar in Magento 2 Checkout Page

The default Magento 2 checkout, though it is well developed, cannot be enough for every business requirements. There is always a room for improvement in checkout page to change its visual appeal and the flow.

So, whether it is for business requirements or improvements, you would want to try new things in Magento 2 checkout page.

One such example is to move apply coupon to side bar in Magento 2 checkout page.

Instead of offering the “apply coupon” in the payment section, the below solution lets you implement it in the shipping section as shown below:

How to Move Apply Coupon to Sidebar in Magento 2 Checkout Page

Rearranging the apply coupon can be easily done with this programmatic method:

Steps to Move Apply Coupon to Side Bar in Magento 2 Checkout Page:

  1. Create registration.php file in app\code\[Vendor]\[Namespace]\
  2. Create module.xml file in app\code\[Vendor]\[Namespace]\etc
  3. Create checkout_index_index.xml file in app\code\[Vendor]\[Namespace]\view\frontend\layout

That’s it.

Follow the above steps and you can offer the “Apply Coupon” button in the shipping section itself on the checkout page.

Please let me know if you have any doubts about the implementation. I’d be happy to help. Also, I would like to know how this solution helped you improve the checkout functionality in Magento 2 store.

I’d be grateful if you help me share this post to fellow developers via social media.

Thank you.

 

5
(based on 10 Reviews)
How to Move Apply Coupon to Sidebar in Magento 2 Checkout Page

Sanjay Jethva

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. Owing to his contributions in Magento Forums and posting solutions, he is among the top 50 contributors of the Magento community in 2019. When he is not engrossed with anything related to Magento, he loves to play cricket.

4 Comments

  • raj

    Hello,
    The code is working fine, but it is duplicating, showing on middle content and sidebar, is there a way to add only in sidebar and remove from middle content.

    Thanks

    • Sanjay Jethva

      Hello Raj,

      Please try to add this code in checkout_index_index.xml just before <item name=”sidebar” xsi:type=”array”>.

      <item name=”steps” xsi:type=”array”>
      <item name=”children” xsi:type=”array”>
      <item name=”billing-step” xsi:type=”array”>
      <item name=”children” xsi:type=”array”>
      <item name=”payment” xsi:type=”array”>
      <item name=”children” xsi:type=”array”>
      <item name=”afterMethods” xsi:type=”array”>
      <item name=”children” xsi:type=”array”>
      <item name=”discount” xsi:type=”array”>
      <item name=”config” xsi:type=”array”>
      <item name=”componentDisabled” xsi:type=”boolean”>true </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      Thank you

  • Rustam

    Sanjay thanks for this article!

    Can you please advise how to move the “Apply Coupon” field to Sidebar int he basket (cart) page?
    Thanks in advance.

Leave a Reply

Your email address will not be published. Required fields are marked *