-
Notifications
You must be signed in to change notification settings - Fork 219
Create CountryInput component #1574
Comments
Issue-Label Bot is automatically applying the label Links: app homepage, dashboard and code for this bot. |
I think the So I would create the |
What data source are you intending to use?
The best place to consume this data is to get it from Woo (with translation and all), so new API endpoints might be required. |
My idea was to use the values returned by I was planning to set those values in the settings and directly read them from there instead of creating a new API endpoint, which seemed to be overwhelming. But I don't have a strong opinion on that, since we will need an API endpoint anyway for the CountryInput. |
I also don’t have strong opinions about this as well, but this data might be big so I'm not sure if we should include it with every |
We can conditionally populate the wcSettings global using the Long term it'd be nice to use a new endpoint devoted to this (is there already one?). Before doing anything on this though, have you investigated what wc-admin is doing for country/state selectors? I don't think there's anything publicly exposed yet but I'm pretty sure there's something in their client code. It'd be useful I think to evaluate what wcAdmin is doing and see if that's something we can collaborate on so we have something usable by both. |
seems it does exactly what we need. |
Thanks for linking that endpoint @nerrad. If I'm not wrong, that endpoint lists all countries, which is not exactly what we need here, we only want countries where the store ships or sells. AKA instead of We could update that endpoint to receive a new parameter to know which method to use. Does that make sense? I'm not used to work with the In any case, I will create a PR with the
Yes, I did take a look at their implementation of the country autocompleter and it's also listing all countries. For WooCommerce Admin it makes sense: you might have stopped selling to a country, but you might still want to filter data from previous customers from that country. But in our case we should only list countries were the store sells/ships. |
@nerrad @mikejolley Would make it sense updating the countries endpoint of |
Hmm, it sounds like something that should be a resource on the /shipping/ endpoint? So something like |
We would need an endpoint to return the shipping countries ( |
I'm not sure I understand fully what the difference is between |
The endpoint only supports the first use-case. But for the Cart and Checkout blocks we need the second and third. So we either extend that endpoint or we create a new one. In the UI, you can find these settings in WooCommerce > Settings: Hope that helps. 🙂 |
Thanks Albert, I probably could have taken the time to figure that out myself but I appreciate the explanation ❤️ . I'm happy to defer to @mikejolley 's thoughts on this. From my perspective:
|
@Aljullu The countries endpoint being used now is not from the store API correct? Thus requires auth. Is that suitable? Since the list of countries is static, would it make sense to include this via wcSettings? |
Oh, good point. We would need all users to have access to it.
That was my initial thought as well, and how it's currently implemented. But that solution would not escale well for counties/states/provinces because the list will be much larger. Given that for counties/states/provinces we will need an endpoint, we thought it made sense loading countries from and endpoint as well. Does that make sense? |
@Aljullu Hmm what is the concern with the large data set? Using an API will cause noticeable delay when changing countries since you'll need to wait for states to come back. Is that also a concern? States might be needed conditionally, but countries won't. You always need the full list. |
I think it would make more sense to differ states and counties until everything is loaded and the user started filling his form, however, some browsers do offer full autocomplete to all fields, so I'm not sure how will that play with a field that didn’t load yet, could we possibly use the MaxMind Geolocation to decide what we want to serve initially? |
@mikejolley so if I understand you correctly, you propose to have both (countries & counties) in
@senadir yeah... I think we would have this issue anyway no matter if we have the values pre-loaded or we load them through an endpoint. Because we need one of the selects to change based on the value of another one so both can't be filled in parallel. But it might be worth doing some testing once we have the forms set up. |
Putting countries and counties (states/provinces) in |
I created a follow-up (#1752) for the last task of this issue, so closing this one. |
Part of #1348.
We need an input field that allows introducing a country.
This is how it currently looks in the Cart page:
Breakdown
CustomSelect
toComboboxControl
(issue: Migrate CountryInput and StateInput to ComboboxControl #1752).The text was updated successfully, but these errors were encountered: