---
title: "Limit variants on each product"
url: https://docs.woolytech.com/en/articles/235-limit-variants-on-each-product
collection: "Getting started"
updated: 2026-11-13
language: en
---

# Limit variants on each product

# Variant Limiting Rules

This guide explains how Shopify merchants can control which variants are included in a feed using **Limit number of variants on each product**.

  

The feature is rule-based and supports:

-   Limiting variants per product (e.g., keep only the first 3 variants)
    
-   Limiting variants per option group (e.g., keep max 2 variants per Color)
    
-   Conditional rules using expressions (e.g., apply a rule only when the product title contains “A”)
    
-   “Stacking” rules so a variant must satisfy multiple limits at the same time (e.g., max 3 variants total, but max 2 of them can be Red)
    

* * *

## Where to find it

Open your feed settings and go to: **Limit number of variants on each product**

You can add multiple rules and reorder them by dragging.

* * *

## Key concepts

### 1) Rules are evaluated in order (top → bottom)

Rules are applied in the order you see them in the UI.

-   The first matching non-stacked rule can decide whether a variant is kept or removed.
    
-   Stacked rules can run together (see **Stacking** below).
    

### 2) Each rule creates a “quota”

Each rule has a **Limit**:

-   **Limit = 0**: remove all variants that match this rule (useful for “skip” logic).
    
-   **Limit = N (N > 0)**: keep up to **N** variants in the rule’s scope.
    

The “scope” can be:

-   The whole product (no option grouping), or
    
-   A group defined by one or more options (e.g., per Color, per Size, per Color+Size).
    

### 3) Grouping by options

A rule can group variants by option values.

For example:

-   “Max 2 variants per Color” means each color is its own group.
    
-   “Max 1 variant per Color + Size” means each Color+Size combination is its own group.
    

### 4) Default behavior (fallback)

Below the rule list there is a **Default** setting (sometimes shown as “Default/First” depending on UI state):

-   **Keep all**: include all variants not removed by rules.
    
-   **Skip all**: remove all variants not matched/kept by rules.
    
-   **Limit**: keep up to a fixed number of variants for the product when no rule matches.
    

Use this to define what happens when none of your rules apply.

* * *

## Rule fields explained

### Limit

The maximum number of variants allowed for the rule’s scope.

-   0 = remove
    
-   1, 2, 3… = keep up to that many
    

### Matching

Determines how option grouping works:

-   **Any option**: no grouping (the rule applies to the whole product). The Options field is not used.
    
-   **All options**: all listed options must exist for a variant; the group key is the combination of all option values.
    
-   **Most options**: uses whichever listed options exist; group key is the combination of available option values.
    
-   **First option**: uses the first listed option that has a value.
    

### Options

Used only when **Matching** is not “Any option”.

Enter one or more Shopify option names separated by commas, for example:

-   `Color`  
    
-   `Size`  
    
-   `Color, Size`  
    

Important:

-   Option names must match your Shopify product option names (case/spacing should match what you see in Shopify admin).
    

### When (condition expression)

This field is optional:

-   Leave it empty to apply the rule unconditionally.
    
-   Fill it to apply the rule only when the expression evaluates to true.
    

Expressions can reference feed tokens (wrapped in single quotes), for example:

-   `'{product_title}'`   – product title
    
-   `'{product_options}'`   – a text summary of product options (e.g., “Color: Red, Blue; Size: S, M”)
    
-   `'{pa_color}'`   – the current variant’s Color value
    
-   `'{pa_size}'`   – the current variant’s Size value
    

Common operators you can use:

-   `and`  , `or`  , `not`  
    
-   `==`   equals
    
-   `~=`   contains / regex match (case-insensitive)
    

Examples:

-   Product title contains “A”: `'{product_title}' ~= "A"`  
    
-   Variant color is exactly Red: `'{pa_color}' == "Red"`  
    
-   Product does not have a Size option, one of the following methods can be used:
    
    -   Variant’s Size value is empty: `empty('{pa_size}')`
        
    -   Based on the option summary text: `not ('{product_options}' ~= "Size:")`
        
-   The size option contains one or two values: `'{pav_size#count}' == 1 or '{pav_size#count}' == 2`
    

### Stack with other stacked rules (stack toggle)

If you have multiple rules, you may see a “stack” toggle (icon button) on each rule.

-   When stacking is **OFF** for a rule:
    
    -   The first matching rule can decide a variant’s keep/remove outcome (rule order matters a lot).
        
-   When stacking is **ON** for a rule:
    
    -   The variant must satisfy _all_ stacked limits that match it.
        
    -   This is ideal for combined constraints like:
        
        -   “Max 3 variants total, but max 2 can be Red”
            
        -   “Max 2 per Color, but max 1 per Size=M”
            

* * *

## Practical recipes

### 1) Skip variants by condition

To skip variants matching a condition, create a rule with **Limit = 0** and a **When** condition.

Example: skip all variants when product title contains “B”:

-   Limit: `0`  
    
-   Matching: `Any option`  
    
-   When: `'{product_title}' ~= "B"`  
    

Then set Default to **Keep all** (so other products keep their variants).

### 2) Keep only variants with a specific Size

Example: keep only Size = M for Clothing:

Rule A (remove everything that is not M):

-   Limit: `0`  
    
-   Matching: `Any option`  
    
-   When: `('{product_type}' ~= "Clothing") and ('{product_options}' ~= "Size:") and ('{pa_size}' != "M")`  
    

Default: **Keep all**.

This pattern is powerful because “Limit = 0” acts like an exclusion filter.

### 3) Keep max 2 variants per Color

Rule:

-   Limit: `2`  
    
-   Matching: `All options`  
    
-   Options: `Color`  
    
-   When: (empty)
    

Default: **Keep all**.

### 4) Combined rule: max 3 variants total, but max 2 Red

Create two rules and turn stacking ON for both:

Rule 1 (total cap):

-   Limit: `3`  
    
-   Matching: `Any option`  
    
-   When: (empty)
    
-   Stack: ON
    

Rule 2 (Red cap):

-   Limit: `2`  
    
-   Matching: `Any option`  
    
-   When: `'{pa_color}' == "Red"`  
    
-   Stack: ON
    

Default: **Keep all**.

### 5) If product has no Color option, limit to 1 per Size

Rule:

-   Limit: `1`  
    
-   Matching: `All options`  
    
-   Options: `Size`  
    
-   When: `not ('{product_options}' ~= "Color:")`  
    

Default: **Keep all**.

* * *

## Tips & troubleshooting

### Option name mismatch

If a rule using Options doesn’t work:

-   Confirm your Shopify option names (e.g., “Colour” vs “Color”, “Ring Size” vs “Size”).
    
-   Try a simpler rule first (Matching = Any option) to confirm the rule is being applied.
    

### Case and whitespace

String matching is often case sensitive for equality (`==`  ).

If your data varies (e.g., “red” vs “Red”), prefer `~=`   with a regex:`'{pa_color}' ~= "^red$"`  

### Rule order matters

If stacking is OFF, earlier rules can “win”.

Place the most specific rules above more general ones.

### Start simple

Build and verify rules step-by-step:

1.  Add one rule.
    
2.  Preview the feed output.
    
3.  Add the next rule only after the first works as expected.
