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 entire flow automation is shown in the image below:
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.
Click on the action “Order LineItems” and connect it to the trigger.
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 }}
Our team can help you set up this Shopify Flow automation for your store, customized to your specific needs and business requirements.
Contact Us