如何从Magento 2的结帐流程中删除“公司”字段?


13

如何从Magento 2的结帐流程中删除“公司”字段?我一直在寻找模板,但没有找到它。

更新:是否可以通过布局或模板删除此字段?


我目前无法在手机上查看,但我认为它与Knockout JS模板有关。您可以搜索表单中的任何内容,例如类或ID吗?
本·克鲁克

运送字段在:内form id="co-shipping-form"。commpany字段的代码:<div class="field" name="shippingAddress.company" data-bind="visible: visible, attr: {'name': element.dataScope}, css: additionalClasses">"
路易斯·加西亚

Answers:


17

暂时,我们应该尝试:

<item name="company" xsi:type="array">
    <item name="visible" xsi:type="boolean">false</item>
</item>

例如,在中 app/design/frontend/{Vendor Theme}/{Theme}/Magento_Checkout/layout/checkout_index_index.xml,找到您需要自定义的组件。将相应的节点和所有父节点复制到。我们将删除/禁用电话和公司字段:

<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="steps" xsi:type="array">
                                    <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="children" xsi:type="array">
                                                        <!-- The name of the form the field belongs to -->
                                                        <item name="shipping-address-fieldset" xsi:type="array">
                                                            <item name="children" xsi:type="array">
                                                                <!--Remove fields-->
                                                                <item name="telephone" xsi:type="array">
                                                                    <item name="visible" xsi:type="boolean">false</item>
                                                                </item>
                                                                <item name="company" xsi:type="array">
                                                                    <item name="visible" xsi:type="boolean">false</item>
                                                                </item>
                                                            </item>
                                                        </item>
                                                    </item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

[编辑]:

从Magento 2.2.x

STORES>配置>客户>客户配置>名称和地址选项>显示公司>否


1
它没有用
路易斯·加西亚


2
STORES>配置>客户>客户配置>名称和地址选项>显示公司>否此代码可以正常工作。
Shubham Jaiswal '18

10

**Magento 2.1**使用以下步骤隐藏了公司字段:

复制句柄文件 app/design/frontend/PackageName/ThemeName/Magento_Checkout/layout/checkout_index_index.xml

替换以下代码:

<item name="company" xsi:type="array">
        <item name="validation" xsi:type="array">
            <item name="min_text_length" xsi:type="number">0</item>
        </item>
</item>

<item name="company" xsi:type="array">
        <item name="visible" xsi:type="boolean">false</item>                                                                                                
        <item name="validation" xsi:type="array">
            <item name="min_text_length" xsi:type="number">0</item>
        </item>
</item>

仅足够使用<item name="visible" xsi:type="boolean">false</item>
LucScu


5

您应该尝试将false设置为visible属性:

<item name="company" xsi:type="array">
    <item name="visible" xsi:type="boolean">false</item>
</item>



0

vendor / magento / module-checkout / view / frontend / layout / checkout_index_index.xml

找:

<item name="company" xsi:type="array">
<item name="validation" xsi:type="array">
<item name="min_text_length" xsi:type="number">0</item>
</item> 
</item>

更换:

<item name="company" xsi:type="array">
<item name="visible" xsi:type="boolean">false</item>  
<item name="validation" xsi:type="array">
<item name="min_text_length" xsi:type="number">0</item>
</item>
</item>

它适用于Magento 2.1.9
Atish Dipankar Baidya

您建议您编辑不好的核心,而应使用最佳做法以正确的方式替换该值,以设置此值
Xenocide8998 '18
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.