> ## Documentation Index
> Fetch the complete documentation index at: https://discountkit.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Storefront data

> Access discount data through product, collection, and shop metafields

Discount Kit Live makes your discount data instantly accessible through metafields using an app-specific namespace.

## Accessing Discount Data

Discount data is available through metafields on products, collections, and the shop object using the namespace `app--9549316097--discount_kit` and key `discounts`.

### Product-Level Discounts

Access all discounts that apply to a specific product, including discounts inherited from collections the product belongs to:

```liquid theme={null}
{% assign discounts = product.metafields.app--9549316097--discount_kit.discounts.value %}

{% if discounts.size > 0 %}
  {% for discount in discounts %}
    <div class="discount">
      <h3>{{ discount.discount_title }}</h3>
      <span>{{ discount.maximum_reward_value }}% OFF</span>
    </div>
  {% endfor %}
{% endif %}
```

### Collection-Level Discounts

Access discounts that target a collection directly. Note that these discounts are also fanned out to every product in the collection, so you typically only need collection metafields for collection page banners:

```liquid theme={null}
{% assign discounts = collection.metafields.app--9549316097--discount_kit.discounts.value %}

{% if discounts.size > 0 %}
  <div class="collection-promo">
    <p>{{ discounts.first.discount_title }}</p>
  </div>
{% endif %}
```

### Shop-Level Discounts

Access all active discounts across your store:

```liquid theme={null}
{% assign all_discounts = shop.metafields.app--9549316097--discount_kit.discounts.value %}

{% if all_discounts.size > 0 %}
  <div class="site-wide-promos">
    {% for discount in all_discounts %}
      <div>{{ discount.discount_title }}</div>
    {% endfor %}
  </div>
{% endif %}
```

## DiscountSummary Object

Each discount in the array is a [DiscountSummary](/live/reference) metaobject with fields like:

* `discount_title` — Display name
* `discount_type` — Type (PRODUCT\_VOLUME, ORDER\_GOAL, GWP, etc.)
* `method` — `'automatic'` or `'code'`
* `code` — The discount code (empty for automatic discounts)
* `tags` — Tags applied to the discount in Shopify (includes `dk:live` plus any merchant tags)
* `reward_type` — PERCENTAGE, FIXED\_AMOUNT, or FIXED\_PRICE
* `maximum_reward_value` — Top tier discount value
* `included_markets` — Market handles where applicable
* `included_customer_tags` — Required customer tags
* `cart_attribute_key` — Cart attribute key required to apply

## Quick Access: Best Discount Value

For simple use cases where you just need to display the best discount value, Discount Kit provides scalar metafields that are easier to work with than parsing the full discount array.

<Note>
  Both `max_reward_percent` and `max_reward_cents` are always present, but only one will have a non-zero value. Percentage discounts are preferred over fixed-value discounts (fixed-amount or fixed-price). When a product or collection has no active discounts, both values are `0`.
</Note>

<Warning>
  These scalar metafields only reflect **universal discounts** that apply to all visitors. Test mode discounts, GWP discounts, customer-tagged discounts, and market-specific discounts are excluded from scalar computation. They still appear in the full `discounts` array. See the [data reference](/live/reference) for details.
</Warning>

### Available Metafields

| Metafield             | Type                   | Description                                                                                                               |
| --------------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| `max_reward_percent`  | `number_decimal`       | Best percentage discount (e.g., `20` for 20% off)                                                                         |
| `max_reward_cents`    | `number_integer`       | Best fixed-value reward in cents (discount amount or final price, e.g., `500` for $5 off or `1500` for a $15 final price) |
| `max_reward_discount` | `metaobject_reference` | Reference to the full DiscountSummary for additional details                                                              |

### Product Example

```liquid theme={null}
{% assign percent_off = product.metafields.app--9549316097--discount_kit.max_reward_percent.value %}
{% assign cents_off = product.metafields.app--9549316097--discount_kit.max_reward_cents.value %}

{% if percent_off %}
  <span class="badge">{{ percent_off | round }}% OFF</span>
{% elsif cents_off %}
  <span class="badge">{{ cents_off | divided_by: 100.0 | money }} OFF</span>
{% endif %}
```

### Collection Example

```liquid theme={null}
{% assign percent_off = collection.metafields.app--9549316097--discount_kit.max_reward_percent.value %}

{% if percent_off %}
  <div class="collection-badge">
    Save up to {{ percent_off | round }}%
  </div>
{% endif %}
```

### Accessing the Full Discount Details

Use `max_reward_discount` to get additional info like the discount title or message:

```liquid theme={null}
{% assign best_discount = product.metafields.app--9549316097--discount_kit.max_reward_discount.value %}

{% if best_discount %}
  <div class="promo">
    <strong>{{ best_discount.discount_title }}</strong>
    <span>{{ best_discount.maximum_reward_value | round }}% OFF</span>
  </div>
{% endif %}
```

## Performance

Metafield access is instant with zero overhead:

* **No API calls** - Data is already on the page
* **Server-rendered** - Available during initial render
* **Always up-to-date** - Synced automatically

## Next Steps

* Learn about [filtering discounts](/live/filtering-discounts) by method, market, customer tags, and cart state
* See the complete [DiscountSummary reference](/live/reference)
* Explore [code examples](/live/examples)
