Update product metafield when a product has incoming inventory

Update product metafield when a product has incoming inventory

daveuk100
Tourist
8 0 3

The overall goal is to show a badge on every product listing like "restocking soon" if the product has inventory.incoming > 0 (e.g. a purchase order has been created and the product has incoming stock on it's way).

 

I don't want to use a 3rd party app for this, and I want to avoid modifying liquid directly in my templates (today I do this, and am I trying to avoid it moving forward...).

 

Today, I modify my prestige template theme (product-badges.liquid) to have an extra piece of code:

 

  {% if variant.available == false and variant.incoming %}
    <span class="badge badge--custom">Restocking soon</span>
  {% endif %}

 

I want to avoid that custom code in the template. I use prestige theme and it has a feature where every product has a metafield called "badges". Any text you put into that metafield will show up on the product listing as a badge (so this is essentially a way of adding custom badges to a product in addition to the defaults like "sold out" etc).

 

I am hoping that there is some automated way (e.g. via Flow) to make it so that whenever a product's "variant.incoming" value is > 0 , the badges metafield on that product is updated to say "Restocking soon". 

 

Can flow do this? either by acting on product update or purchase order creation?

 

Thanks.

Replies 2 (2)

tim
Shopify Partner
4336 502 1590

If i remember correctly, unfortunately Flow does not have relevant triggers.

Other apps do, for example Mechanic has a very similar task https://tasks.mechanic.dev/auto-tag-products-with-incoming-inventory 

 

I totally support your desire to avoid theme code edits to make it easier to update your theme in future.

In your case, I believe you may rather use "Liquid block" to add very similar liquid code:

  {% assign variant = product.selected_or_first_available_variant %}

  {% if variant.available == false and variant.incoming %}
    <span class="badge badge--custom">Restocking soon</span>
  {% endif %}

Screenshot 2025-03-24 at 12.49.09 PM.png

 

If my post is helpful, consider liking it -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com
daveuk100
Tourist
8 0 3

Thanks Tim! Appreciate all the guidance.

 

I agree that's a good solution for the product page badges, but unfortunately the place where I need to see this badge is on the product "cards" that get displayed when you visit a collection page. I am not sure if there is any way to achieve that with a liquid block.