Getting product availability at storefront

Shopify Partner
2 0 0

Hi all,


We are struggling to check if a product or variant is sold out from an embedded scripttag. Currently we check if the button Add To Cart has class aria-disabled="true" or label "Sold out" but this approach is not stable. We'd like to check something from Shopify global variables, such as Shopify or ShopifyAnalytics, but we could not find it out.


Do you have any idea about that ? 


Thank you