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
Trigger
Step 1Trigger fired when a variant's inventory quantity changes.
Condition
Step 2Checks if all variants are in stock.
Action
Step 3Sets the store's default template.
Condition
Step 4Checks if all variants are out of stock.
Action
Step 5Sets the sold-out template.
Condition
Step 6Checks if one or more variants are out of stock.
Action
Step 7Sets the variant-sold-out template.
Step-by-Step Setup
- 1
Start a new Flow with the 'Product variant inventory quantity changed' trigger.
- 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
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
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
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.
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
How to Get Email Alerts for Low Product Variant Inventory
Automate internal email notifications instantly when any product variant's inventory dips below your critical threshold, ensuring you never miss a restock opportunity.
How to Automatically Hide Out-of-Stock Products on Shopify
Automatically unpublish products from your online store when inventory hits zero, and republish them when restocked, ensuring customers always see available items.
Automatically Republish Back-in-Stock Products
Automatically make products visible on your online store the moment they come back in stock, ensuring customers can purchase without delay.