Sitecore Commerce 9: How to Disable Address Validation for State/Country

Andrei Paliakou on November 28, 2019

Sitecore Commerce 9: Disable Address validation for State/Country

On one of my project I got a requirement to support all countries and cities from all over the world. If you install Storefront site from scratch you can see that OOTB Sitecore supports only two regions: Canada and United States.

The problem is that you need to create all regions and cities manually in Commerce Control Panel and assign them to Country-Region Storefront configuration. It’s a huge work for content editors.

When you create customer address, submit shipping and billing checkout steps commerce engine validates county and city based on Country-Region Storefront configuration. In my case I looked for any solution, which can just disable validation for State/County.

After some investigation I found, that Sitecore.Commerce.Core.ValidatePartyBlock is responsible for this validation. ValidatePartyBlock is a part of IValidatePartyPipeline. If you don’t need validation for State/County you can just remove this block from IValidatePartyPipeline in your ConfigureSitecore.cs:

I hope it’s useful hack to disable validation for State/County.