We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

    Today we are going to talk about how to remove the postcode field in checkout in Magento 2?

    The field is dynamically created from EAV attributes on the LayoutProcessor class.

    All we need to do is to set is_user_defined to 1 for the postcode eav_attribute. I recommend doing this via a setup resource, like this:

    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        /** @var MagentoCustomerSetupCustomerSetupFactory $customerSetup */
        $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
    
        $setup->startSetup();
    
        $attribute = $customerSetup->getEavConfig()->getAttribute('customer_address', 'postcode');
        $attribute->setIsUserDefined(1)->save();
    
        $attribute->save();
    }

    also, we need to remove validation for that, so we can direct set 0 to DB in eav_attribute table

    that’s it.

     

    field_5bfb909c5ccae

      Get a Free Quote