Re: Storefront API - filtering on 'in stock only'

Storefront API - filtering on 'in stock only'

dev88
Tourist
11 0 6

Hi guys,

 

Is there a way to filter products that are 'in stock only' in my storefront api call? Can you show me an example?

Replies 2 (2)

dev88
Tourist
11 0 6

Found it 🙂

 

{
   shop {
       products(first: 10, query: "published_status:published AND available_for_sale:true")

   }

}

oscprofessional
Shopify Partner
16115 2409 3123

Hello 
i) Using Admin Product API you can get all products array. used below Admin API to get Products

'store_url/admin/products.json'

ii) get the "variants" from products array
iii) get "inventory_quantity" from "variants" array
iv) if "inventory_quantity" is grater than "0" then product is "In Stock" otherwise product is "Out of Stock"

Get pass your Store Core Web Vital Free Speed Optimization Audit, Chat on WhatsApp | Skype : oscprofessionals-87 | Email: [email protected] | Hire us | Guaranteed Site Speed Optimization | Website Free Audit | Shopify Theme Customization | Build Shopify Private App | Shopify SEO | Digital Marketing | Oscp Upsell & Cross sell App : Free | Oscp Sales & Volume Discount App : Free | Custom Pricing Wholesale App : Free