0

I have created Custom Tabs in Magento 2 Between Shipping and Review and Payment.

I want to remove Discount Coupon Code from Review and Payment to my Custom Tabs.How will i do it ?

I think this part is used to show coupan in checkout_index_index.xml

<item name="summary" xsi:type="array">
<item name="children" xsi:type="array">
    <item name="discount" xsi:type="array">
        <item name="component" xsi:type="string">Magento_SalesRule/js/view/payment/discount</item>
        <item name="children" xsi:type="array">
            <item name="errors" xsi:type="array">
                <item name="sortOrder" xsi:type="string">0</item>
                <item name="component" xsi:type="string">Magento_SalesRule/js/view/payment/discount-messages</item>
                <item name="displayArea" xsi:type="string">messages</item>
            </item>
        </item>
    </item>
</item>
But doesn't show up the fields.
2
  • do you mean you want to remove default place of coupen code block? Jul 28, 2020 at 7:46
  • Yes I want remove default coupon block and add it to my Custom Tab.@DhirenVasoya
    – Prits
    Jul 28, 2020 at 8:00

1 Answer 1

1

To remove Coupon Code block create the following file.

Vendor\Extension\view\frontend\layout\checkout_index_index.xml

Add this code into that file.

<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.root">
        <arguments>
            <argument name="jsLayout" xsi:type="array">
                <item name="components" xsi:type="array">
                    <item name="checkout" xsi:type="array">
                        <item name="children" xsi:type="array">
                            <item name="steps" xsi:type="array">
                                <item name="children" xsi:type="array">
                                    <item name="billing-step" xsi:type="array">
                                        <item name="component" xsi:type="string">uiComponent</item>
                                        <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>
                        </item>
                    </item>
                </item>
            </argument>
        </arguments>
    </referenceBlock>
</body>

Main logic is into this line, which remove that block.

<item name="componentDisabled" xsi:type="boolean">true</item>
12
  • Yes it has removed the discount coupan from checkout page Thanks for that but how would i add that coupan in my custom tab @Dhiren
    – Prits
    Jul 28, 2020 at 9:07
  • that depend on, how you added tab there. If above answer help you up-vote and accept as solution, so it will help other in community. Jul 28, 2020 at 9:26
  • I have created checkout_index_index.xml in my custom module and created checkout js file and after that in template folder created html files for the same. If you need further code i have attached it @Dhiren
    – Prits
    Jul 28, 2020 at 9:38
  • Have you check the default block code? you can take reference of that one. Jul 28, 2020 at 10:33
  • Which default block code i didn't understand it will you please explain this @Dhiren
    – Prits
    Jul 28, 2020 at 10:37

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.