0

I moved the Discount block from the billing-step to the Sidebar in the Magento 2 checkout. I disabled the original discount block in the billing-step but I am still getting the following JS error:

knockout.js:303 Uncaught Error: You cannot apply bindings multiple times to the same element.

Below is my layout/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="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 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>
                                <item name="sidebar" xsi:type="array">
                                    <item name="children" xsi:type="array">
                                        <item name="summary" xsi:type="array">
                                            <item name="children" xsi:type="array">
                                                <item name="summary-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>
                </argument>
            </arguments>
        </referenceBlock>
        <move element="logo" destination="checkout"/>
        <referenceBlock name="megamenu" remove="true" />
        <referenceBlock name="top.search" remove="true" />
        <referenceBlock name="minicart" remove="true" />
        <referenceBlock name="top.links.wishlist" remove="true" />
        <referenceContainer name="checkout.header.wrapper" remove="true"/>
        <referenceContainer name="header" remove="true" />
        
        
    </body>
</page>

Any assistance would be appreciated. Am I missing a step?

0

As per my knowledge this error will come when you are calling same instance of the template from 2 different way.

I mean you have to remove first block and create that new instance in your new location.

If this helps then hit like.

Enjoy your coding and improve by debugging !!! :)

Hiren Patel

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.