# How to split order by variant/product metafield

## Splitting by Metafields

This guide explains how to create split rules based on variant metafields.

### Correct Format

The format for metafield-based split rules is:

```
Metafield:key:value
```

**Example:** `Metafield:presale:Presale`

This will split variants where the metafield with key `presale` has the value `Presale`.

### Format Options

#### Match a specific key and value

```
Metafield:key:value
```

* **Example:** `Metafield:presale:Presale`
* Matches variants where the metafield with key `presale` has the value `Presale`

#### Match any metafield with a specific value

```
Metafield:value
```

* **Example:** `Metafield:Presale`
* Matches variants where ANY metafield has a value of `Presale`

### Important: Namespace vs Key

Shopify metafields have both a **namespace** and a **key**. For example, a metafield might be defined as `customer.presale` where:

* `customer` is the namespace
* `presale` is the key

**When creating split rules, use only the key (not the namespace).**

| Metafield Definition                       | Correct Rule                     | Incorrect Rule                          |
| ------------------------------------------ | -------------------------------- | --------------------------------------- |
| `customer.presale` with value `Presale`    | `Metafield:presale:Presale`      | `Metafield:customer.presale:Presale`    |
| `custom.restock_date` with value `2024-03` | `Metafield:restock_date:2024-03` | `Metafield:custom.restock_date:2024-03` |

### Variant Metafields

The system reads **variant metafields** (up to 20 per variant). The matching is performed on variant-level metafields, so you can split orders based on metafields assigned to specific product variants.

### Product Metafields

You can also split by **product metafields** (metafields on the product, not the variant). Use the `ProductMetafield:` prefix instead.

#### Match a specific key and value

```
ProductMetafield:key:value
```

* **Example:** `ProductMetafield:warehouse:US`
* Matches products where the metafield with key `warehouse` has the value `US`

#### Match any metafield with a specific value

```
ProductMetafield:value
```

* **Example:** `ProductMetafield:fragile`
* Matches products where ANY metafield has a value of `fragile`

#### When to use Product vs Variant Metafields

| Scenario                                           | Use                          |
| -------------------------------------------------- | ---------------------------- |
| Metafield is set on individual variants            | `Metafield:key:value`        |
| Metafield is set on the product itself             | `ProductMetafield:key:value` |
| Different variants have different metafield values | `Metafield:key:value`        |
| All variants share the same metafield value        | `ProductMetafield:key:value` |

### Common Mistakes

1. **Including the namespace:** Use `Metafield:presale:Presale`, not `Metafield:customer.presale:Presale`
2. **Missing the Metafield prefix:** Use `Metafield:presale:Presale`, not `presale:Presale`
3. **Wrong separator format:** Use `Metafield:key:value`, not `Metafield:key=value`

### Examples

| Use Case                                             | Rule                                   |
| ---------------------------------------------------- | -------------------------------------- |
| Split variants marked as presale                     | `Metafield:presale:true`               |
| Split variants with a specific restock date          | `Metafield:restock_date:2024-03`       |
| Split variants where any metafield equals "dropship" | `Metafield:dropship`                   |
| Split variants with fulfillment type "warehouse"     | `Metafield:fulfillment_type:warehouse` |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ordersplitpro-co.gitbook.io/ordersplitpro/basics/how-to-split-order-by-variant-product-metafield.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
