Product and ProductVariant objects need `availableForSaleOnline` field

Detecting whether product or variant is in stock is very common and important task. Shopify API has availableForSale field on ProductVariant object, which gives us this information in easy way. But this field works only for simple shops with online-only locations.

Large brands (mostly Shopify Plus) often have offline stores that are not fulfilling online orders. And for them using availableForSale to determine out of stock status is not possible. They might have inventory in offline store but empty stock for online sales. availableForSale will still return true in that case.

Here’s an example:


The current workaround is to use sellableOnlineQuantity field to understand if variant is out of stock:

out_of_stock?: data.variants.edges.all? do |v|
  v.node.inventoryItem.tracked && v.node.inventoryPolicy == "DENY" && v.node.sellableOnlineQuantity <= 0
end

But it’s an extra work for developers and with the migration to 2048 variants it’s also VERY difficult to do on scale. Because we have to query and paginate not only on products, but also on all variants to detect if product is out of stock.

I believe the better solution would be adding field availableForSaleOnline for both Product and ProductVariant object. This will save a lot of developers pain and will remove the need to fetch and paginate variants for many apps.

Let me know what you think.