Hapus anak komponen UI melalui Layout XML


15

Bagaimana cara menghapus komponen anak UI melalui Layout XML? Misalnya, dari direktif xml di bawah ini checkout_index_index.xml. Bagaimana cara menghapus simpul pengiriman?

<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="totals" xsi:type="array">
                    <item name="children" xsi:type="array">
                        <item name="subtotal" xsi:type="array">
                            <item name="config" xsi:type="array">
                                <item name="title" xsi:type="string" translate="true">Subtotal</item>
                            </item>
                        </item>
                        <item name="shipping" xsi:type="array">
                            <item name="config" xsi:type="array">
                                <item name="title" xsi:type="string" translate="true">Estimated Shipping</item>
                            </item>
                        </item>
                        <item name="grand-total" xsi:type="array">
                            <item name="config" xsi:type="array">
                                <item name="title" xsi:type="string" translate="true">Estimated Total</item>
                            </item>
                        </item>
                    </item>
                </item>
            </item>
        </item>
    </item>
</item>

Node pengiriman dapat dihapus menggunakan plugin tapi saya hanya berpikir harus ada cara yang lebih baik seperti atribut remove node.

Jawaban:


23

Kita dapat membaca dokumen di sini: http://devdocs.magento.com/guides/v2.0/howdoi/checkout/checkout_customize.html . Dalam kasus Anda: kami dapat menerapkan panduan ini:

<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="sidebar" xsi:type="array">
                                    <item name="children" xsi:type="array">
                                        <item name="summary" xsi:type="array">
                                            <item name="children" xsi:type="array">
                                                <item name="totals" xsi:type="array">
                                                    <item name="children" xsi:type="array">
                                                        <!--Remove fields-->
                                                        <item name="subtotal" xsi:type="array">
                                                            <item name="config" xsi:type="array">
                                                                <item name="componentDisabled" xsi:type="boolean">true</item>
                                                            </item>
                                                        </item>
                                                        <item name="shipping" xsi:type="array">
                                                            <item name="config" xsi:type="array">
                                                                <item name="componentDisabled" xsi:type="boolean">true</item>
                                                            </item>
                                                        </item>
                                                        <item name="grand-total" 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>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

Hasil:

masukkan deskripsi gambar di sini

Baca lebih lanjut di sini: http://devdocs.magento.com/guides/v2.1/howdoi/checkout/checkout_customize.html#disable-a-component

[EDIT]

Nonaktifkan sidebar (Ringkasan pesanan) di halaman checkout.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout"
      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="config" xsi:type="array">
                                        <item name="componentDisabled" xsi:type="boolean">true</item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

masukkan deskripsi gambar di sini


Dengan menggunakan situs kami, Anda mengakui telah membaca dan memahami Kebijakan Cookie dan Kebijakan Privasi kami.
Licensed under cc by-sa 3.0 with attribution required.