Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hi,
I’m using this code in my store:
var client = ShopifyBuy.buildClient({ domain: '***namesite***.myshopify.com', storefrontAccessToken: ‘***CODE***' }); var productTitle = $('.product-area__details__title').text(); client.product.fetchQuery( {query: 'title:*'+productTitle+'*'} ).then(function(products) { // Your product is at products[0] if successful //console.log(products[1].variants[0].available); $.each(products, function(key, value) { var titleVariant = value.variants[0].title; var inventory_quantity = value.variants[0].available; $('.metafields').each(function() { var metafields = $(this); var metafieldsValue = $(this).attr('data-order').replace(/\s/g,''); if(metafieldsValue == titleVariant) { if(inventory_quantity == false) { metafields.addClass("unavailable"); } } }); }); });
In this documentation https://shopify.dev/changelog/cleaning-up-deprecations-in-the-storefront-api, it indicates that the “ProductVariant.available” is deprecated.
I cannot understand if what I use in my javascript code (value.variants[0].available) is this indicated value (“ProductVariant.available”).
Is the same value?
Also I received an email from Shopify that said:
"One or more of your custom apps have made deprecated API calls in the last 30 days. Support for these versions will be removed on January 1, 2023 to allow for continued infrastructure improvements. Please update the apps listed below to
API version 2022–07 or later to ensure they continue to function correctly:
Breaking changes affecting Storefront
Could this interfere with the above code in any way?
Thanks
Yeah, I'm having the same issue, for some reason I don't have access to the metafields anymore in our store!