# Variant Metafield Price

We’ve introduced a powerful new discount type inside **Unified Discounts → General Discounts** called **Variant Metafield Price**.

<figure><img src="https://2844543096-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcVBfwy7Yj4tU8TsxkHEr%2Fuploads%2Fqs1XoW74tBrWgbV7dwsS%2Fimage.png?alt=media&#x26;token=06fee0a8-45f4-4936-bc31-fa1f59819fac" alt=""><figcaption></figcaption></figure>

This discount type allows you to:

* Pull discount values directly from a **Variant metafield (JSON type)**
* Retrieve a specific **key** from that JSON
* Apply the discount dynamically based on how you interpret the value

This is ideal for brands that want to **reduce config size**, simplify complex setups, and store pricing logic directly at the variant level.

***

### Why Use Variant Metafield Price?

Instead of:

* Creating multiple large discount configs
* Hardcoding tier logic in multiple places
* Managing dozens of group conditions

You can:

✅ Store discount data inside the variant\
✅ Keep Unified Discount configs lightweight\
✅ Scale across hundreds of products easily\
✅ Maintain pricing in one place (the variant)

***

## How It Works

Each variant contains a **JSON metafield** that stores discount values.

The discount reads:

1. The **Namespace.Key**
2. The **JSON key**
3. Interprets the value as:
   * Fixed Amount Off
   * Percentage Off
   * Specific Price

***

### Step 1: Create a Variant JSON Metafield

Go to:

**Shopify Admin → Settings → Custom Data → Variants → Add Definition**

1. Name it (example: `pricing_information`)
2. Select type: **JSON**
3. Save

You now have a JSON metafield attached to variants.

***

### Step 2: Store Pricing Data Inside the Variant

Inside a variant, populate the JSON metafield like this:

```json
{
  "price_1_6": 575,
  "price_7_12": 550,
  "price_13_plus": 525
}
```

You can store:

* Specific prices
* Fixed discounts
* Percentage discounts
* Or multiple pricing tiers inside the same JSON

***

### Step 3: Configure Variant Metafield Price Discount

Go to:

**Unified Discounts → General Discounts → Create Discount**

Select:\
**Discount Type: Variant Metafield Price**

You’ll see three important fields:

#### 1️⃣ Metafield Namespace.Key

Example:

```
custom.pricing_information
```

#### 2️⃣ Value Key from Metafield

Example:

```
price_1_6
```

This tells the discount which key to read from the JSON.

#### 3️⃣ Value Interpretation

Choose how the value should be applied:

* **Fixed Amount Off**
* **Percentage Off**
* **Specific Price**

Example:\
If the JSON value is `575` and interpretation is **Specific Price**,\
the product price becomes **575**.

***

## Example: Tiered Pricing (1–6, 7–12, 13+)

Let’s say your store has:

* 1–6 units → $575
* 7–12 units → $550
* 13+ units → $525

Instead of creating large legacy discount configs, you can:

#### Create 3 Groups in Unified Discount

***

#### Group 1: 1–6 Units

Condition:

* Line quantity < 7

Value Key:

```
price_1_6
```

Interpretation:\
**Specific Price**

***

#### Group 2: 7–12 Units

Condition:

* Line quantity > 6
* Line quantity < 13

Value Key:

```
price_7_12
```

Interpretation:\
**Specific Price**

***

#### Group 3: 13+ Units

Condition:

* Line quantity ≥ 13

Value Key:

```
price_13_plus
```

Interpretation:\
**Specific Price**

***

Now the discount engine:

✔ Checks the condition\
✔ Reads the correct JSON key from the variant\
✔ Applies the value dynamically

No hardcoded price logic inside the discount config.

***

## Subscription vs One-Time Example

You can also store multiple pricing types:

```json
{
  "fixedoff_onetime": 9,
  "fixedoff_sub": 5,
  "selling_price": 742
}
```

Then:

#### Config 1 – One-Time Users

Conditions:

* Order count = 0
* Selling plan = false

Key:

```
fixedoff_onetime
```

Interpretation:\
**Fixed Amount Off**

***

#### Config 2 – Subscription Users

Conditions:

* Selling plan = true

Key:

```
fixedoff_sub
```

Interpretation:\
**Fixed Amount Off**

***

The same variant JSON powers multiple discount scenarios.

***

## Real-World Use Case

If you previously used legacy discounts for tier pricing and noticed inconsistencies (for example 7–12 works but 13+ doesn’t), switching to **Unified Discount + Variant Metafield Price** is the recommended approach.

Why?

* Legacy discounts are older implementations.
* Unified Discounts are more scalable and actively supported.
* Variant Metafield Price reduces config complexity significantly.

***

## Best Practices

* Fill the JSON metafield for every variant you want the discount to apply to
* Keep your JSON keys consistent across products
* Use “All” discount allocation type when appropriate
* Use descriptive keys (price\_1\_6, sub\_discount, vip\_price, etc.)

***

## When Should You Use This?

This feature is perfect if:

* You have many SKUs with different pricing tiers
* You manage complex subscription vs one-time pricing
* You want pricing logic stored at the product level
* You want smaller, cleaner discount configs
* You are migrating from legacy discount setups

***

## Summary

**Variant Metafield Price** lets you:

* Store discount logic in variant JSON
* Pull values dynamically
* Interpret them as:
  * Fixed Amount Off
  * Percentage Off
  * Specific Price
* Build scalable and future-proof pricing systems

If you have any questions or need help setting this up, feel free to reach out.
