I have created new address attribute hide_address
with yes no value. Using setup script:
if(version_compare($context->getVersion(), '1.0.2', '<')) {
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerSetup = $objectManager->create('Vendor\Module\Setup\CustomerSetup2');
$customerSetup->installAttributes($customerSetup);
}
In CustomerSetup2.php I have used this code:
public function installCustomerAddressAttributes($customerSetup)
{
$customerSetup->addAttribute('customer_address',
'hide_address',
[
'label' => 'Hide Address',
'system' => 0,
'user_defined' => true,
'position' => 100,
'sort_order' => 100,
'visible' => true,
'default_value' => '',
'note' => '',
'type' => 'int',
'input' => 'boolean',
'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
]
);
$customerSetup->getEavConfig()->getAttribute('customer_address', 'hide_address')->setData('is_user_defined', 1)->setData('default_value', '')->setData('used_in_forms', ['adminhtml_customer_address', 'customer_register_address', 'customer_address_edit'])->save();
}