Shopify Flow/Inventory & Restock/Automate Product Template Changes by Variant Stock Status
Operational EfficiencyHigh Difficulty

Automate Product Template Changes by Variant Stock Status

Automatically switch your product page template between 'in stock,' 'sold out,' and 'partial stock' based on real-time variant inventory levels.

The Problem

Manually updating product templates for stock changes is a time-consuming, error-prone task that can lead to frustrating customer experiences. Showing an 'Add to Cart' button for an out-of-stock item or an empty page for a partially stocked product means lost sales, confused customers, and missed opportunities to capture leads or cross-sell.

What This Automation Solves

This Flow eliminates manual template changes by triggering on `Product variant inventory quantity changed`. It then uses 'If' conditions to check if `all variants inventory > 0`, `all variants inventory <= 0`, or `at least one variant no inventory`, applying your designated 'in stock,' 'sold out,' or 'partial stock' product templates via the `Send Admin API request` action.

When to Use This Automation

  • You sell products with multiple variants (e.g., sizes, colors) where stock levels fluctuate independently.
  • You want to display different calls to action or information (like a 'notify me' form) based on product availability.
  • You want to provide a superior customer experience by instantly reflecting product stock status on the page layout.

Workflow

  1. Trigger

    Step 1

    Trigger fired when a variant's inventory quantity changes.

  2. Condition

    Step 2

    Checks if all variants are in stock.

  3. Action

    Step 3

    Sets the store's default template.

  4. Condition

    Step 4

    Checks if all variants are out of stock.

  5. Action

    Step 5

    Sets the sold-out template.

  6. Condition

    Step 6

    Checks if one or more variants are out of stock.

  7. Action

    Step 7

    Sets the variant-sold-out template.

Step-by-Step Setup

  1. 1

    Start a new Flow with the 'Product variant inventory quantity changed' trigger.

  2. 2

    Add a 'Condition' block: 'all variants inventory > 0'. If true, use 'Send Admin API request' to set `product.template_suffix` to `null` (for your default template).

  3. 3

    Add a 'Condition' block: 'all variants inventory <= 0'. If true, use 'Send Admin API request' to set `product.template_suffix` to your dedicated 'sold-out' template (e.g., `sold-out`).

  4. 4

    Add a 'Condition' block: 'at least one variant no inventory'. If true, use 'Send Admin API request' to set `product.template_suffix` to your 'partial-stock' template (e.g., `variant-sold-out`).

  5. 5

    Ensure your theme has custom product templates (e.g., `product.sold-out.liquid`, `product.variant-sold-out.liquid`) prepared to be called by Flow.

Related Questions

How do I create custom product templates in my Shopify theme?
You can create custom product templates by navigating to Online Store > Themes > Actions > Edit code. Under 'Templates,' click 'Add a new template,' choose 'product,' and give it a unique name (e.g., 'sold-out').
What is the 'Admin API request' action and how do I use it to change templates?
The 'Admin API request' action allows Flow to directly modify Shopify's data. To change a product template, you'll use a PUT request to the `products/{product.id}` endpoint with a JSON body like `{"product": {"id": {{ product.id }}, "template_suffix": "your-template-name"}}`.
Can this Flow distinguish between a product being 'temporarily out of stock' versus 'discontinued'?
This Flow primarily reacts to inventory quantity. For 'discontinued' status, you'd typically archive the product or use a separate tag-based Flow to set a specific 'discontinued' template, as inventory alone doesn't differentiate.
How can I ensure my 'sold-out' or 'partial-stock' templates are customer-friendly?
Edit the Liquid files for these custom templates to include clear messages, options like 'email me when back in stock' forms, links to similar products, or pre-order buttons if applicable, enhancing the customer journey.

Recommended Tools & Apps

Launch this automation

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

Open Shopify Flow

Merchant Insight

Don't just hide out-of-stock products or show a blank page. Your custom 'sold-out' and 'partial-stock' templates are prime real estate for lead capture (email sign-ups), suggesting alternatives, or educating customers. Optimize them to reta

Related Automations