0

This is original file in code dir of a third part module:

<?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="head.additional">
            <block class="Amasty\Checkout\Block\Onepage\Head" name="amasty.checkout.head"  template="Amasty_Checkout::onepage/head.phtml" after="-"/>
        </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="component" xsi:type="string">Amasty_Checkout/js/view/onepage</item>
                            <item name="children" xsi:type="array">
                                <item name="sidebar" xsi:type="array">
                                    <item name="component" xsi:type="string">uiComponent</item>
                                    <item name="displayArea" xsi:type="string">sidebar</item>
                                    <item name="config" xsi:type="array">
                                        <item name="template" xsi:type="string">Amasty_Checkout/onepage/sidebar-summary</item>
                                    </item>
                                    <item name="children" xsi:type="array">
                                        <item name="additional" xsi:type="array">
                                            <item name="component" xsi:type="string">Amasty_Checkout/js/view/additional/fieldset</item>
                                            <item name="provider" xsi:type="string">checkoutProvider</item>
                                            <item name="config" xsi:type="array">
                                                <item name="deps" xsi:type="array">
                                                    <item name="0" xsi:type="string">checkoutProvider</item>
                                                </item>
                                            </item>
                                            <item name="children" xsi:type="array">
                                                <item name="subscribe" xsi:type="array">
                                                    <item name="component" xsi:type="string">Amasty_Checkout/js/view/additional/subscribe</item>
                                                    <item name="description" xsi:type="string" translate="true">Sign Up for Our Newsletter</item>
                                                    <item name="dataScope" xsi:type="string">amcheckout.additional.subscribe</item>
                                                    <item name="provider" xsi:type="string">checkoutProvider</item>
                                                    <item name="checked" xsi:type="boolean">false</item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

I want to hide the element but extending the XML layout file in my custom theme. This is my extended XML file, however, I can't get it to work... Element is still visible on the frontend.

<?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="component" xsi:type="string">Amasty_Checkout/js/view/onepage</item>
                            <item name="children" xsi:type="array">
                                <item name="sidebar" xsi:type="array">
                                    <item name="children" xsi:type="array">
                                        <item name="additional" xsi:type="array">
                                            <item name="children" xsi:type="array">
                                                <item name="subscribe" xsi:type="array">
                                                    <item name="visible" xsi:type="boolean">false</item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

Is it even possible to hide the element by extending the XML file or do I have to create a custom module and set up a preference for it?

1 Answer 1

0

It sounds like you're looking for how to disable a component rather that make it invisible, if you want it to function but not be visible use opacity: 0; or visibility: hidden; in CSS.

How to disable a component Instructions taken from the dev docs:

<item name="%the_component_to_be_disabled%" xsi:type="array">
    <item name="config" xsi:type="array">
        <item name="componentDisabled" xsi:type="boolean">true</item>
    </item>
</item>

So in your case:

...
    <item name="subscribe" xsi:type="array">
        <item name="config" xsi:type="array">
                <item name="componentDisabled" xsi:type="boolean">true</item>
            </item>
        </item>
    </item>
...
1
  • The thing is, I don't want to disable the functionality of the element, but also, don't want to keep it in the DOM for no reason. I moved the element in the extended XML file and I want to remove the redundant one. I guess this cannot be achieved then can it?
    – Greg
    Commented May 22, 2019 at 15:05

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.