Regularly update variant-level metafields via app/API

Topic summary

Goal: Build a Shopify app that automatically generates and updates a variant-level “shipping message” metafield (e.g., “Product ships in 4–6 business days”) based on changing factors (availability, tags, other metafields updated by a third-party), ideally hourly.

Proposed approach:

  • Select a collection, fetch products, iterate variants, read inputs (availability, tags, metafields), compute the message, and update the variant’s metafield on a schedule. Metafields = custom fields attached to Shopify resources; variant-level in this case.

Key guidance/update:

  • The overall process is sound. If the app is only for the merchant’s own store, you can skip the “select a collection” UI and hardcode the scope.
  • Use the Shopify Admin REST Metafields API to create/update variant metafields (documentation link shared, with a product variant example).

Status/outcome:

  • High-level direction provided; no detailed scheduling/implementation specifics discussed.
  • Thread appears informally resolved with acknowledgment; no additional open questions raised.
Summarized with AI on January 21. AI used: gpt-5.

Hi there! This is my first time posting so please be gentle!

I have a Shopify store that sells a limited number of products, but I am looking to expand. I want to build a Shopify app that automates the process of generating a specific string for each product variant that will be saved as a variant-level metafield.

I can figure out the coding myself - I would just appreciate some high-level guidance on what exactly I need to build. This is my first time building an app, so any ideas are appreciated.

Summary of project:

Each product variant in the store needs to have a ‘shipping message’ metafield. This metafield is a string that will look something like this:

‘Product ships in 4-6 business days’

The exact syntax and date-range of each variant’s metafield will be determined by on the basis of a number of factors (product availability, product tags, certain other metafields). I have written the logic for generating this string - so I do not need any guidance on this front.

The aforementioned factors that determine the exact syntax and date-range of the string can change on a day-by-day basis. One of the metafields is updated regularly by a third-party app. A variant’s availability can change when the product is sold out. I change product’s tags fairly regularly too.

For this reason, I want to build an app that updates each variant’s ‘shipping message’ metafield on a regular basis - perhaps every hour.

I have set up a basic embedded app using the Shopify CLI 3.0. Now I’ve done this, I’m a bit lost. Here is what I’m guessing I need to do:

  1. Set up some kind of simple interface so that the app’s user can select a collection that contains all the store’s products.

  2. Once this collection has been selected, the ID of that collection will be used to retrieve a list of every product in that collection.

  3. From there, each of each products’ variant can be looped through.

  4. Once at the variant-level, various information about that variant can be grabbed (product availability, product tags, certain other metafields).

  5. With this information, I would (i) generated each variant’s shipping message using the pre-written logic, and (ii) replace its current ‘shipping_message’ metafield with the newly generated shipping message.

[repeat steps 2-5 every hour]


If anybody could give me any pointers, suggestions ideas about which APIs I should use, how they should be implemented, and any best practices that I should follow, I would be really grateful.

Thanks for taking the time to read this!

Hey @gut_und_gunstig

That process sounds solid to me.

If the app is for your own store, you could skip the “select a collection” step / hardcode.

You’ll want to use the Metafields API to create/update metafields. There’s a product variant example on this page: https://shopify.dev/docs/api/admin-rest/2023-04/resources/metafield#put-blogs-blog-id-metafields-metafield-id

Good luck!

Thanks very much for your help!

1 Like