-
Notifications
You must be signed in to change notification settings - Fork 263
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
Support for inventory quantity #753
Comments
I was just looking for this last night. Support for this would be amazing! Is anyone taking pull requests to make this happen? |
Quick update on this. I've forked the repo and followed the contribution guide to attempt a pull request for this change. I'm assuming it simply requires updating the I've tried updating the package locally with the above changes but still receive the error:
I'm guessing that in addition to these changes, Shopify needs to "enable" these fields on the API server. I wonder if @StefanSlehta or @rebeccajfriedman could offer some guidance on which files to edit. Happy to do the work to make it happen. |
@StefanSlehta Awesome thank you! |
Hey just an update, you can also expand the queries you'd like to use instead of adding to the |
Thanks for the direction. I managed to get the However I do have another question:
Since I'm expanding the query I wouldn't need to submit a PR. Thanks again! |
Just updated to |
You rock! |
@arobbins @StefanSlehta Thanks for this! Would you guys mind posting a short example on how to expand the query to pull the inventory field? I checked the link but can't get the query right. Thanks! |
I'm building a static site (nextjs) that uses a useEffect hook to pull the available qty. const productAvailableQty = (handle) => {
const qtyQuery = shopify.graphQLClient.query((root) => {
root.add(
"productByHandle",
{ args: { handle: `${handle}` } },
(product) => {
product.add("title");
product.add("handle");
product.add("id");
product.addConnection(
"variants",
{ args: { first: 99 } },
(variant) => {
variant.add("id");
variant.add("availableForSale");
variant.add("quantityAvailable");
}
);
}
);
});
return shopify.graphQLClient
.send(qtyQuery)
.then((res) => JSON.parse(JSON.stringify(res.model.productByHandle)))
.catch(() => null);
}; |
@obelmont what do you mean by saying that the quantity is not tracked? |
@50bbx It means that the product's available inventory is not tracked in Shopify. It's an option in the Inventory section of each product in Shopify's admin panel that is used to determine available stock to ensure you don't sell more than you have. |
@obelmont I get when I run the query :( |
@socreative try |
@ktaftaf That's for the regular Shopify API, Storefront uses I do have the correct access in the Shopify App as I can query the quantityAvailable field with a standard GQL query at build time. @obelmont Could you confirm that your code is still working for you? Trying the same code results in the schema error for me... EDIT: Found the answer, you need to change from the standard SDK to the unoptimized one (the last one here: https://github.com/Shopify/js-buy-sdk#builds) |
@obelmont I tried to use your code and i am getting |
I have the same problem. Tried to access quantityAvailable from variant and it seems it is not in there. |
I wonder if this is related to: Shopify/storefront-api-feedback#101 |
Found the issue for |
I have provided both read_inventory access in the storefront and tracking the quantity still getting |
Any ideas? |
Reinstall Shopify GraphQl app.
…On Wed, May 17, 2023, 01:02 Alex Walton ***@***.***> wrote:
No field of name "quantityAvailable" found on type "ProductVariant" in
schema
or
No field of name "inventoryQuantity" found on type "ProductVariant" in
schema
Any ideas?
—
Reply to this email directly, view it on GitHub
<#753 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AP6YQNBIAAA7CZ5KSQ5A5DLXGPI4VANCNFSM4MIL34SQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
@Mritunjay004 As in un-install then re-install the app in the Shopify apps area? |
https://shopify-graphiql-app.shopifycloud.com/login
Here is the link while downloading also select the scopes.
Cheers!!
…On Wed, May 17, 2023, 02:38 Mritunjay ***@***.***> wrote:
Yup
On Wed, May 17, 2023, 01:46 Alex Walton ***@***.***> wrote:
> @Mritunjay004 <https://github.com/Mritunjay004> As in un-install then
> re-install the app in the Shopify apps area?
>
> —
> Reply to this email directly, view it on GitHub
> <#753 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AP6YQNBI6RY6UXTXOOCQALDXGPOCHANCNFSM4MIL34SQ>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
Yup
…On Wed, May 17, 2023, 01:46 Alex Walton ***@***.***> wrote:
@Mritunjay004 <https://github.com/Mritunjay004> As in un-install then
re-install the app in the Shopify apps area?
—
Reply to this email directly, view it on GitHub
<#753 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AP6YQNBI6RY6UXTXOOCQALDXGPOCHANCNFSM4MIL34SQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
The issue for me was I had to have 'unauthenticated_read_product_inventory' included in my scopes. This is not in the documentation, but was showing as an error in the response. |
Hey, great job maintaining the libarary!
Curious to hear when could we access the product variant's
quantityAvailable
field?https://shopify.dev/changelog/inventory-quantity-available-on-storefront-graphql-api
Link to API reference
The text was updated successfully, but these errors were encountered: