Not possible to create optional choice lists

Hi there,

I’m trying to set up a metafield or metaobject to allow a Choice List of possible US states for the merchant to easily pick from.

The intent is so they can conditionally show some messaging in the frontend on a product page based on the customer’s zip code.

However, not all products have this need. So sometimes the list can be empty.

However, metafields or metaobjects don’t allow empty choice lists?

Whenever I try to save the metafield or metaobject definition for a choice list with 0 minimum, the validation fails:

Hey Dylan, I think you just want to leave that min item count to be blank instead of 0?

Oh wow I cannot believe I missed that @James_Lunan

Yes, leaving it defined fixed that!

No worries. It’s good to have an easy answer sometimes.

I see that you’re wanting to put states into the choice list? States will work but you mention zip codes as well in your use case. It’s prudent to mention the maximum of 128 items in a choice list, which won’t accommodate all zip codes so I’m assuming you’ll figure out zip codes in separate metafield or elsewhere entirely.

Thanks!

Right, there are other zip level conditions. This one is state level.

I worked around the limitations by making 39k metaobject entries (zip is the handle) we have other zip associated data as well.

But allowing the staff to pick between 50 states helps with the validation as well.

Any tips for reusing the states list? I guess I could make a metaobject reusable for many metafields, not sure if that’s good practice.

I’m not sure I fully understand the use case but, yes, a Metaobject is exactly how I would remove the need to re-create a list of items multiple times to assign to different metafield definitions.