Create customer address attribute Programmatically using Patch data in Magento 2.3

We can create a customer address attribute programmatically in Magento 2 using the simple module by latest way 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. Continue reading “Create customer address attribute Programmatically using Patch data in Magento 2.3”

How to ignore address validation error in Magento 2?

You can ignore address validation for shipping and billing address when you create address programmatically or sometimes you don’t need to worry about validation for billing or shipping address.

Make sure addresses will be saved without validation errors, You need to use setShouldIgnoreValidation(true) function on quote object. Continue reading “How to ignore address validation error in Magento 2?”

Delete Customer Address by address id Programmatically Magento 2.

You can delete the specific customer address by address id using AddressRepositoryInterface interface.

Magento\Customer\Api\AddressRepositoryInterface contains the deleteById($addressId) function with pass first argument as address id to fetch specific customer address data. Continue reading “Delete Customer Address by address id Programmatically Magento 2.”