Shopify Flow/Scheduled & Maintenance/How to Track & Update Product Discount Percentages Automatically
Operational EfficiencyMedium Difficulty

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

  1. Trigger

    Step 1

    Every 10 minutes, does not end

  2. Action

    Step 2

    Get recently updated products

  3. Action

    Step 3

    Processes product data to find maximum discount percentages per product

  4. Loop

    Step 4

    item in runCode.products

  5. Condition

    Step 5

    discount does not match the existing value for the metafield

  6. Action

    Step 6

    Update the product metafield for the discount amount

Step-by-Step Setup

  1. 1

    Set the trigger to 'Scheduled time' and configure it to run every 10 minutes without an end date.

  2. 2

    Add a 'Get product data' action to retrieve all products updated within the last 10 minutes.

  3. 3

    Insert a 'Run code' action to process the fetched product data, calculating the maximum discount percentage for each product's variants.

  4. 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. 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.

Open Shopify Flow

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