0

I want to show a discount form on the checkout page. I have added this below code on

checkout_index_index.xml

<?xml version="1.0"?>
<!--
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<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="breadcrumbs">
        <action method="addCrumb">
            <argument name="crumbName" xsi:type="string" translate="true">Home</argument>
            <argument name="crumbInfo" xsi:type="array">
                <item name="title" xsi:type="string" translate="true">Home</item>
                <item name="label" xsi:type="string" translate="true">Home</item>
                <item name="link" xsi:type="string" translate="true">{{baseUrl}}</item>
            </argument>
        </action>
        <action method="addCrumb">
            <argument name="crumbName" xsi:type="string" translate="true">Check Out</argument>
            <argument name="crumbInfo" xsi:type="array">
                <item name="title" xsi:type="string" translate="true">Check Out</item>
                <item name="label" xsi:type="string" translate="true">Check Out</item>
            </argument>
        </action>
    </referenceBlock>
    <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="component" xsi:type="string" translate="true">uiComponent</item>
                                <item name="displayArea" xsi:type="string" translate="true">steps</item>
                                <item name="children" xsi:type="array">
                                    <item name="shipping-step" xsi:type="array">
                                        <item name="children" xsi:type="array">
                                            <item name="shippingAddress" xsi:type="array">
                                                <item name="config" xsi:type="array">
                                                    <item name="popUpForm" xsi:type="array">
                                                        <item name="options" xsi:type="array">
                                                            <item name="buttons" xsi:type="array">
                                                                <item name="save" xsi:type="array">
                                                                    <item name="text" xsi:type="string" translate="true">Save Address</item>
                                                                    <item name="class" xsi:type="string" translate="true">action primary btn btn-custom action-save-address</item>
                                                                </item>
                                                                <item name="cancel" xsi:type="array">
                                                                    <item name="text" xsi:type="string" translate="true">Cancel</item>
                                                                    <item name="class" xsi:type="string" translate="true">action secondary btn btn-custom3 action-hide-popup</item>
                                                                </item>
                                                            </item>
                                                        </item>
                                                    </item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                                <item name="children" xsi:type="array">
                                    <item name="payment" xsi:type="array">
                                        <item name="children" xsi:type="array">
                                            <!--Disable default coupon-->
                                            <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>
                                            <!--Add new coupon to beforeMethod region-->
                                            <item name="beforeMethods" 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>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </item>
            </argument>
        </arguments>
    </referenceBlock>
    <move element="logo" destination="header"/>
    <referenceContainer name="checkout.header.wrapper" remove="true"/>
</body>

Discount form its not showing. I want to display the above shipping address.

Thanks

0
<?xml version="1.0"?><page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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">
                                                    <!--Disable default coupon-->
                                                    <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>
                                                    <!--Add new coupon to beforeMethod region-->
                                                    <item name="beforeMethods" 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>
                                                    </item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </item>
            </argument>
        </arguments>
    </referenceBlock>
</body>

  • I have added the code, Still, discount form not appearing. Please check the updated code. – Sudhakar SJ Nov 22 at 7:12
  • I have edited my answer please check. – Dinesh Rajput Nov 22 at 7:20
  • A discount form showing two times in payment page. Please refer to this screenshot. (prnt.sc/q0g4hs) – Sudhakar SJ Nov 22 at 7:49
  • Can you tell me how to remove discount form below payment method. – Sudhakar SJ Nov 22 at 7:50
  • Have you added "<!--Disable default coupon-->" section as above code mentioned ? – Dinesh Rajput Nov 22 at 9:27

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.