---
title: Unit pricing
description: Learn how to display unit pricing in your theme.
source_url:
  html: 'https://shopify.dev/docs/storefronts/themes/pricing-payments/unit-pricing'
  md: 'https://shopify.dev/docs/storefronts/themes/pricing-payments/unit-pricing.md'
api_name: liquid
---

# Unit pricing

If a merchant sells products in specific quantities or measurements, they might need to display a price per unit for those products. For example, if a product is sold in weights of 500g, 1kg, and 1.5kg, a merchant might want to show the price per 100g for each variant.

In this tutorial, you'll learn how to display unit prices for product variants.

**Tip:**

Unit prices can be added to products [through the Shopify admin](https://help.shopify.com/manual/products/details/product-pricing/unit-pricing#add-unit-prices-to-your-product).

***

## Resources

To display unit prices in your theme, you'll use the following:

* The `unit_price` property on the [`line_item`](https://shopify.dev/docs/api/liquid/objects/line_item#line_item-unit_price) or [`variant`](https://shopify.dev/docs/api/liquid/objects/variant#variant-unit_price) objects
* The [`unit_price_measurement`](https://shopify.dev/docs/api/liquid/objects/unit_price_measurement) object

Depending on where you're implementing your unit price display, you'll access unit price information through the associated parent object:

| Context | Example template types | Parent object |
| - | - | - |
| Variants that have been added to a cart or are part of an order | * [cart](https://shopify.dev/docs/storefronts/themes/architecture/templates/cart) | [line\_item](https://shopify.dev/docs/api/liquid/objects/line_item) |
| Product and variant listings | - [product](https://shopify.dev/docs/storefronts/themes/architecture/templates/product)
- [collection](https://shopify.dev/docs/storefronts/themes/architecture/templates/collection) | [variant](https://shopify.dev/docs/api/liquid/objects/variant) |

***

## Implementing unit price displays

You should add support for unit prices wherever you have a price display. Common locations include:

* The collection template
* The product template
* The cart template

You can include this code in the relevant template or a section in the template.

Your code should do the following:

1. Check whether the variant or line item has a unit price measurement using [`variant.unit_price_measurement`](https://shopify.dev/docs/api/liquid/objects/variant#variant-unit_price_measurement) or [`line_item.unit_price_measurement`](https://shopify.dev/docs/api/liquid/objects/line_item#line_item-unit_price_measurement).
2. If the variant or line item uses a unit price measurement, then use the [`unit_price_with_measurement` filter](https://shopify.dev/docs/api/liquid/filters/unit_price_with_measurement) to display the unit price based on the store's [**HTML without currency** setting](https://help.shopify.com/manual/payments/currency-formatting).

## Example

##### variant

```liquid
{% if variant.unit_price_measurement %}
  {{ variant.unit_price | unit_price_with_measurement: variant.unit_price_measurement }}
{% endif %}
```

##### line\_item

```liquid
{% if line_item.unit_price_measurement %}
  {{ line_item.unit_price | unit_price_with_measurement: line_item.unit_price_measurement }}
{% endif %}
```

1. Use [money filters](https://shopify.dev/docs/api/liquid/filters/payment_button#money-filters) combined with the [`unit_price_with_measurement` filter](https://shopify.dev/docs/api/liquid/filters/unit_price_with_measurement) to display the unit price with a different money format.

## Example

##### variant

```liquid
{% if variant.unit_price_measurement %}
  {{ variant.unit_price | money_with_currency | unit_price_with_measurement: variant.unit_price_measurement }}
{% endif %}
```

##### line\_item

```liquid
{% if line_item.unit_price_measurement %}
  {{ line_item.unit_price | money_with_currency | unit_price_with_measurement: line_item.unit_price_measurement }}
{% endif %}
```

***
