How to Track & Update Product Discount Percentages Automatically
This Flow continuously updates a product metafield with the highest discount percentage, ensuring your promotional data is always current for marketing and reporting.
The Problem
Manually tracking product discounts is a time-consuming, error-prone chore, especially for stores with frequent sales or dynamic pricing. Missing a deep discount can lead to inaccurate campaign targeting, lost revenue from under-promoted deals, or frustrated customers expecting a certain offer. This often means hours spent compiling spreadsheets or relying on outdated data, costing valuable marketing time and potential sales.
What This Automation Solves
This automation solves that by running every 10 minutes, using the 'Get product data' action to fetch recently updated products. It then processes this data with the 'Run code' action to identify the highest discount percentage across all product variants. If a new, more significant discount is found, the 'Send Admin API request' action updates a dedicated product metafield, keeping your discount data perpetually fresh and ready for use.
When to Use This Automation
- Running frequent sales, flash deals, or dynamic pricing changes across many products.
- Segmenting customers or building email/SMS campaigns based on specific discount depths.
- Displaying accurate 'X% Off!' badges or discount labels directly on product pages via theme customizations.
Workflow
Trigger
Step 1Every 10 minutes, does not end
Action
Step 2Get recently updated products
Action
Step 3Processes product data to find maximum discount percentages per product
Loop
Step 4item in runCode.products
Condition
Step 5discount does not match the existing value for the metafield
Action
Step 6Update the product metafield for the discount amount
Step-by-Step Setup
- 1
Set the trigger to 'Scheduled time' and configure it to run every 10 minutes without an end date.
- 2
Add a 'Get product data' action to retrieve all products updated within the last 10 minutes.
- 3
Insert a 'Run code' action to process the fetched product data, calculating the maximum discount percentage for each product's variants.
- 4
Add a 'Loop' to iterate through the products found by the code, followed by a 'Condition' to check if the new calculated discount differs from the existing metafield value.
- 5
Use 'Send Admin API request' within the loop to update the product metafield with the determined discount percentage only when a change is detected.
Related Questions
- How can I display this calculated discount percentage on my product page?
- Once this Flow updates the product metafield, your theme or a compatible app can read and display its value dynamically on product pages, collection pages, or even in search results, showcasing the current highest discount.
- Can I use this metafield for email marketing segmentation in platforms like Klaviyo?
- Absolutely. Integrations with email marketing platforms like Klaviyo often allow you to pull product metafields, enabling you to segment customers based on products with specific discount levels for targeted campaigns.
- What happens if a product has multiple variants with different discounts?
- The 'Run code' step is specifically designed to identify and store the *highest* discount percentage found across all variants of a single product, ensuring you always highlight the most compelling offer.
- How accurate is the 'recently updated products' filter for finding changes?
- The 'Get product data' action, configured to look for products updated within the last 10 minutes (matching the schedule), ensures the Flow efficiently processes only relevant items, maintaining high data accuracy without unnecessary load.
Recommended Tools & Apps
Launch this automation
Open Shopify Flow and use this page as your setup blueprint.
Merchant Insight
Pro-tip: Name your metafield something descriptive like `products.metafields.custom.max_discount_percentage`. This makes it easy for your theme developer or marketing apps to consistently reference and use this dynamic discount data across
Related Automations
Automate Tagging for Shopify Subscription Orders
Instantly tag every recurring subscription order with a specific label, streamlining order identification and management within your Shopify admin.
How to Get Email Alerts for Shopify Flow Errors
Automatically receive an email notification whenever one of your critical Shopify Flow automations encounters an error, preventing silent failures and revenue loss.
Automate Deleting Old, Non-Purchasing Customers
Automatically cleans your customer database by removing profiles of non-purchasing customers older than five years, ensuring a streamlined and compliant system.