#Help with Revalidating listProducts in storefront

10 messages · Page 1 of 1 (latest)

amber agate
#

I have successfully setup product.* product_variant.* and product_option.* event subscribers to revalidate the frontend on changes

But.....

Is there an event which fires when stock (inventory_quantity) changes for a variant?
It is very important to invalidate the cache when a product becomes out of stock for me.

#

it feels very bad to not to cache this API request because its used everywhere. category page, home page, collection page what not...

exotic knot
#

@amber agate

Subscribers:
inventory-item-updated.ts
inventory-level-updated.ts
inventory-reservation-item-updated.ts

You can check these one.

amber agate
#

wha those events exist?

#

lemme see

amber agate
amber agate
#

@exotic knot hey can u pls confirm this? if it does exist, it will really help

marsh gust
#

I think how you do this will depend on what you consider out of stock. If it's when all items are reserved from orders placed, you could hook into the order.placed event to check the inventory levels and notify accordingly. If you consider out of stock when all items are actually shipped, you could hook into fulfillment created instead.

amber agate
marsh gust
#

I don't know the business purpose you have for wanting to know when an item is out of stock. You asked, "Is there an event which fires when stock (inventory_quantity) changes for a variant?" And, yes, there are multiple.