Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

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
16344 2438 3180

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"

Hire us | Pass Core Web Vital | B2B Wholesale Experts | Claim Your Free Website Review |
Connect with Us: WhatsApp | Skype: oscprofessionals-87 | Email: pallavi@oscprofessionals.com |
Custom Shopify SolutionsPrivate Apps, Theme Customization & SEO | Digital Marketing |
OSCP Apps: Discount Suite | Wholesale App | Bundle & Upsell | Shipping Discount | and more...