如何在Checkout移动应用折扣代码选项?

时间:2018-04-06 07:27:26

标签: magento2

如何在付款步骤的“订单摘要”部分之后移动“应用折扣代码”选项。在Vendor / Magento / Sales Rule / view / front-end / layout / checkout_index_index.xml中,我尝试修改item name =“afterMethods”,但id不起作用。

1 个答案:

答案 0 :(得分:0)

首先需要删除主题中的afterMethods组件(调用折扣组件):app/design/frontend/Vendor/themename/Magento_Checkout/layout/checkout_index_index.xml

<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="config" xsi:type="array">
                        <item name="componentDisabled" xsi:type="boolean">true</item>
                    </item>
                </item>
            </item>
        </item>
    </item>
</item>

折扣组件本身在Magento_SalesRule模块中定义。因此,一旦删除,您可以在app/design/frontend/Vendor/themename/Magento_SalesRule/layout/checkout_index_index.xml中的订单摘要组件之后添加对此组件的折扣(类似未经过测试,因此您可能需要修复它):

<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="sidebar" xsi:type="array">
                                <item name="children" xsi:type="array">
                                    <item name="discount" xsi:type="array">
                                        <item name="sortOrder" xsi:type="string">
                                        <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>
            </argument>
        </arguments>
    </referenceBlock>
</body>