Goal: Add two dependent dropdowns in the cart drawer—first select a distributor, then a city filtered by that distributor—and save selections to order/cart attributes.
Initial approach: A code sample added HTML selects and JavaScript that:
Loads distributor names from store metafields.
Loads a distributor→cities JSON map.
Updates Shopify cart attributes via /cart/update.js.
Issue: The distributor list did not populate after setup, and earlier attempts caused the city list to stop appearing after selection.
Metafields guidance conflict:
First guidance: Create store-level metafields (Custom Data → Store): a list for distributors and a multiline JSON city map, referenced via shop.metafields in the cart drawer.
Later guidance: Move metafields to Products instead, switch city mapping to plain text “Distributor: City1, City2”, and claim the JS will read this format (no updated JS provided). This contradicts the original JSON-based script.
Other opinions: One suggestion favored a single combined dropdown or using data attributes if options are small; OP declined due to a large set.
Current status: Unresolved. The OP asked where to enter distributor values and shared a screenshot. Clarification is needed on the correct metafield location, format, and matching JS.
Summarized with AI on December 11.
AI used: gpt-5.
I need to add a dropdown function to my cart drawer. I actually need two of them, where the second one is conditional based on the first one.
For our business, we sell products to customers who have preferred distributors, so we’d like to give customers the option to choose a distributor when checking out. Because our distributors have many locations, we’d like the second dropdown to be for customers to choose a city. So, this would be based on which distributor they select.
I tried adding code to cart-drawer.liquid and while it looks great and works at first, it eventually breaks - specifically, the options for city do not come up after selecting a distributor. Ideally, this is something I can eventually add to order notification notes as well but I need to get this working first.
I’m wondering if this functionality is even possible, or if someone has an app recommendation that can help. Thank you.
Thank you so much for your suggestion and time looking into my issue! I went through all those steps and while it added the dropdowns to my cart-drawer, my list of distributors does not populate. It just tells me to select distributor.
For the metafields steps my settings are a little different. I also never created those before. Can you please confirm this is correct:
If the choices are small just make a single drop down with the distributor + city name.
There’s also whether your doing this backwards by making customers choose a city last especially if not all distributors are in all cities, etc etc.
And using metafields can also be overkill for a small set of options.
And should instead by using data attributes on the first dropdowns options to connect/populate the subsequent dropdowns.
I have a long list of distributors, and each distributor has different cities they have locations in. Because of this, it’s not that user-friendly or visually appealing to have a single dropdown with the distributor + city name. I do like the idea though, and would certainly do this if our list was smaller.
The user flow we want is for customers to choose a distributor, then based on which distributor they choose, they can choose from a list of cities that distributor is in. Our customers have preferred distributors and aren’t really looking based on their desired city, so that is why we want them to choose a distributor first.
I am not too familiar with metafields or data attributes, so if you have any suggestions please let me know. Thank you.
And then there’s do customers know all city names, or is this a distance thing and a visual map would be better etc etc
Plenty of suggestions ,yet actual implementation is an advanced customization beyond the scope of the forums.
You can reach out if you need services.
Other posters will probably provide “AI” generated responses so good luck with that.
All good points to consider, and I really appreciate the input! Though, I just need help with the implementation. We already have the user flow defined.
Customers don’t need to know every city name. Most distributors only have a few locations, though a few have more. There’s no need for distance calculations or a map.
All I need is a dropdown for the list of distributors, and a second dropdown that updates to show the cities based on the selected distributor.
This is the same flow our customers are already used to when placing an order over the phone or via email, they tell us their preferred distributor, then select the location that works best for them.
Thank you so much for your response. Where do I add the distributors? When I did it via Shop, it let me edit values near where it shows delete definition in this screenshot.