Shopify Flow/Fulfillment & Shipping/How to Automatically Mark Products with On-Sale Variants Using Metafields
Operational EfficiencyMedium Difficulty

How to Automatically Mark Products with On-Sale Variants Using Metafields

Automatically identify and tag products with active sales, making it easy to filter, merchandise, and promote discounted items across your store.

The Problem

Merchants often struggle to accurately identify which *products* (not just variants) currently have an active sale, leading to missed opportunities for promotion and merchandising. Manually tracking this across hundreds or thousands of products is a huge time sink, risking outdated sales displays or even promoting items at the wrong price, harming trust and revenue.

What This Automation Solves

This Flow automates the entire process by running on a **scheduled trigger** every 10 minutes. It efficiently checks **if at least one variant of a product is on sale**, then automatically **updates a product metafield** to mark that product as 'on sale,' ensuring real-time accuracy without manual intervention.

When to Use This Automation

  • You need to display 'On Sale' badges on product cards for any product with at least one discounted variant.
  • You want to create automated collections of products that currently have active sales.
  • You're syncing sale product data to a third-party app (like an ad platform or email marketing) that requires a clear 'on sale' flag.

Workflow

  1. Trigger

    Step 1

    Runs every 10 minutes starting Jun 27, 2024.

  2. Action

    Step 2

    Gets up to 10 products updated in the last 10 minutes.

  3. Loop

    Step 3

    Iterates over each product.

  4. Condition

    Step 4

    Checks if any variant is on sale.

  5. Action

    Step 5

    Sets the on-sale metafield.

Step-by-Step Setup

  1. 1

    Configure the 'Scheduled time' trigger to run every 10 minutes.

  2. 2

    Add a 'Get product data' action to fetch products updated in the last 10 minutes.

  3. 3

    Initiate a 'For each' loop to process each retrieved product.

  4. 4

    Create a 'Condition' that checks 'At least one of the product variants is on sale.'

  5. 5

    In the 'Yes' branch, add an 'Update product metafield' action to set your chosen product metafield (e.g., `products.on_sale_variant.boolean`) to `true`.

Related Questions

How can I display an 'On Sale' badge on products using this metafield?
Once the Flow sets the metafield, you can modify your theme's product card snippet to check this boolean metafield and conditionally display an 'On Sale' badge or text.
Can I use this metafield to create automatic product collections?
Yes, you can create an automated collection with the condition 'Product metafield' where `[your_metafield_key]` 'equals' `true` to group all actively discounted products.
What if I want to track products where *all* variants are on sale, not just one?
This specific Flow tracks if *at least one* variant is on sale. To track if *all* variants are on sale, you would need a more advanced Flow condition or a specialized app.
How often should this Flow run to ensure price accuracy?
Running every 10 minutes, as configured, provides near real-time updates, which is generally sufficient to capture price changes quickly without excessive API calls.

Recommended Tools & Apps

Launch this automation

Open Shopify Flow and use this page as your setup blueprint.

Open Shopify Flow

Merchant Insight

To maintain accuracy, remember to also create a 'No' branch in your Flow. This branch should set the `on_sale` metafield to `false` when no variants are on sale, preventing outdated sales tags and ensuring clean data.

Related Automations