Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VariantSelector only support full locale identifier format #2218

Open
qiushihe opened this issue Jun 6, 2024 · 3 comments
Open

VariantSelector only support full locale identifier format #2218

qiushihe opened this issue Jun 6, 2024 · 3 comments
Labels

Comments

@qiushihe
Copy link

qiushihe commented Jun 6, 2024

What is the location of your example repository?

No response

Which package or tool is having this issue?

Hydrogen

What version of that package or tool are you using?

latest

What version of Remix are you using?

No response

Steps to Reproduce

  1. Setup a Hydrogen store
  2. Create a product with more than 1 variant selection (i.e. both "size" and "colour")
  3. Configure the store so it uses URL path to identify locale, by following guide: https://shopify.dev/docs/storefronts/headless/hydrogen/markets/multiple-languages-url-paths, and use the abbreviated locale identifier format (so instead of en-us, use just en which is what the guide uses)
  4. Go to the product page with the abbreviated locale identifier (i.e. /en/products/my-product)
  5. Select a different variant option

Expected Behavior

The variant selection for both variants should be preserved through URL parameters.

Actual Behavior

Only the selected variant option is preserved.

@qiushihe
Copy link
Author

qiushihe commented Jun 6, 2024

The issue actually comes from this line: https://github.com/Shopify/hydrogen/blob/main/packages/hydrogen/src/product/VariantSelector.ts#L179. As you can see, that regular expression only matches the en-us format, and no other formats, despite your own documentations using the abbreviated format.

So, please update that hook so it can support more locale identifier formats: en, and en_US as well.

Thanks!

@frandiox
Copy link
Contributor

frandiox commented Jun 17, 2024

@juanpprieto @blittle should we get the locale from the <VariantSelector> props optionally? Otherwise, maybe we should consider injecting the locale from the server -- we have it in getLocaleFromRequest so we could return it in the root loader and put it in a React provider.

@blittle
Copy link
Contributor

blittle commented Jun 18, 2024

@frandiox @benjaminsehl we are talking about introducing a hydrogen provider. This might be another usecase for doing so. the locale from the request could be passed to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants