Create customer address attribute Programmatically using Patch data in Magento 2.3

Create a customer address attribute programmatically in Magento 2 using the simple module by Best Coding Standard Approach using Setup patch data.

In our demo, I have created a simple text field attribute for a customer address called Nickname.

You can see a customer attribute in backend using Customer -> All Customer -> Click on Edit Customer Link.
Go to Addresses Tab and edit or add new Address.

2 Replies to “Create customer address attribute Programmatically using Patch data in Magento 2.3”

    1. Hi Mohan, You can display this new field in frontend but for that you have to override vendor/magento/module-customer/view/frontend/templates/address/edit.phtml file in your module or theme and add below code in it.

      getAttributeData()->getFrontendLabel('nickname'); ?>

      <input type="text" name="nickname" value="getAddress()->getCustomAttribute('nickname') === null) ? "" : $block->getAddress()->getCustomAttribute('nickname')->getValue(); ?>" title="" class="input-text" id="nickname">

      This is working for me, hope this will work for you. Thank you

Leave a Reply