cancel
Showing results for 
Search instead for 
Did you mean: 

Magento checkout page fields disabling

Magento checkout page fields disabling

Magento checkout page fields disabling
I want to disable some fields in the checkout form. I'm using Magento 2.1.2. How can I disable checkout fields such as company street etc from my checkout form .Can you please help me? 

Tags (1)
3 REPLIES

Re: Magento checkout page fields disabling

Hi @Rijishapk

 

You actually can disable some checkout form fields from checkout_index_index.xml file, however there is backend validation for such fields as First and Last Names, Street, City, Phone Number and Country. So by hiding fields from the form will not help customers to place an order.

 

The app/code/Vendor/Custom/view/frontend/layout/checkout_index_index.xml file:

<?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="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">
<item name="shipping-address-fieldset" xsi:type="array">
<item name="children" xsi:type="array">
<item name="company" xsi:type="array">
<item name="visible" xsi:type="boolean">false</item>
</item>
<item name="street" 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>

 During order placement the \Magento\Quote\Model\QuoteValidator::validateBeforeSubmit() method will check whether Quote is virtual, and if not, it will go and check fields even if they are disabled visually in the shipping form.

 

Best way to do this is to mark Quote have products created as Downloadable, Virtual.

Re: Magento checkout page fields disabling

I can't understand anything. I'm a beginner

Re: Magento checkout page fields disabling

I recommend to start from reading this nice resource: Magento DevDocs.