VizupCommerce

How to update product metafields automatically after each order based on line items?

In this blog article, we will learn how to update product metafields automatically after each order based on line items.

As an example, let’s take the scenario of a Shopify store that accepts donations for a non-profit organization. For each order, the store wants to update the product metafields with the following information:

  • The amount raised so far
  • The goal amount of the donation campaign
  • Total number of people who donated

The entire flow automation is shown in the image below:

Shopify Flow Automation - Update Product Metafields After Each Order

Start with trigger “Order Created”

Click on the trigger and select the “Order Created” trigger by searching for it in Shopify’s inbuilt library of triggers and actions. As of writing this blog article, Shopify exposes 75 triggers and actions.

Shopify Flow Automation - Order Created Trigger

Connect the trigger to the action “Order LineItems”

Click on the action “Order LineItems” and connect it to the trigger.

Shopify Flow Automation - Order LineItems Action

Repeat for each item, connect the action “Update Product Metafields”

Click on the action “Update Product Metafields” and connect it to the trigger.

Select the Metafield raised_amount (create it from Settings -> Custom Data -> Add Products Metafield Definition)

Total the existing raised amount metafield value with the original total amount of the order.

{{ lineItemsForeachitem.product.raisedAmount.value | default: 0 | 
plus: 
lineItemsForeachitem.originalTotalSet.shopMoney.amount  }}
Shopify Flow Automation - Update Product Metafields Action

Need Help Implementing Shopify Flow Automations for your brand?

Our team can help you set up this Shopify Flow automation for your store, customized to your specific needs and business requirements.

Contact Us