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 return isAvailable true for missed variants #2155

Open
vitaliy-bobrov opened this issue May 28, 2024 · 3 comments
Open

VariantSelector return isAvailable true for missed variants #2155

vitaliy-bobrov opened this issue May 28, 2024 · 3 comments
Labels
Bug Something isn't working

Comments

@vitaliy-bobrov
Copy link

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?

2024.4.2

What version of Remix are you using?

No response

Steps to Reproduce

If Product have some missed variants due to availability, ex. T-Shirt with "Color: Green" is not available in "Size: XS", and such variant wasn't added in Shopify admin. In this case VariantSelector will return isAvailable: true for that variant.

The problem is in the line of VariantSelector.ts, line 114 (v 2024.4.2):

isAvailable: variant ? variant.availableForSale! : true,

if variant is not listed in available variants, it should be marked as not available:

isAvailable: variant ? variant.availableForSale! : false,

I'm using a workaround currently to add missed variants with availableForSale: false, but it's quite big amount of code to check for missing variants among all possible combinations. The use-case is for Printful and Shopify integration, as Printful manages available product variants on their side, so you can't manage them in Shopify admin. Printful doesn't allow to add variants that are not available on their side.

Expected Behavior

VariantSelector returns isAvailable: false for missed variants

Actual Behavior

VariantSelector returns isAvailable: true for missed variants

@blittle
Copy link
Contributor

blittle commented May 28, 2024

Hi @vitaliy-bobrov, the problem is that the variants prop is optional. This is because fetching all the variants for a given product can be slow (that's why product options exists). The goal of the code currently is if there is no variant, just assume it's available. Perhaps it could be better and first check if the variants property is defined at all, instead of just the searched for variant.

At the same time, the SFAPI is going to be changing to better allow thousands of product variants, while also providing product availability. This component will be updated once those SFAPI changes are available.

@vitaliy-bobrov
Copy link
Author

@blittle thanks for the quick reply! Now, I understand why it is implemented that way. Maybe it would be worth adding a comment in the code, as it looks like a mistake at first glance, and it is unclear why it defaults to true.

Will the SFAPI update be during the upcoming editions? Could the issue remain open until VariantSelector gets update?

@blittle
Copy link
Contributor

blittle commented May 28, 2024

It's something multiple teams are working on, though I don't have an exact ETA. I'm happy to leave this open until we update the component.

@blittle blittle added the Bug Something isn't working label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants