The Product Discount API enables you to create a new type of discount that is applied to particular product variants or cart lines.


> Deprecated:
> In version 2025-04, the Product Discount API's are deprecated in favour of the [Discount API](/docs/api/functions/reference/discount) and will be sunset in version 2026-04. Learn how to [migrate your Functions to the Discount API](/docs/api/functions/reference/discount/migrate-from-legacy-discount-apis).



## Example use cases

- Money off a product. For example, 20% off shirts.
- Money off a product variant. For example, $5 off blue shirts.
- Money off a cart line. For example, 10% off products with a name engraving option.
- Buy a specific quantity of a product for a specific amount. For example, $5 off up to 2 blue shirts.
- Buy a specific amount of a product, get a second amount at a discount. For example, buy 4 shirts and get 2 blue shirts free.

## Getting started

Follow the getting started tutorials to learn how to customize and extend discounts:

<div class="resource-card-grid">
  <div>
  <a class="resource-card" href="/docs/apps/build/discounts/build-discount-function" data-theme-mode="">
    <div class="resource-card__indicator-container"><img
     src="/assets/resource-cards/function"
     data-alt-src="/assets/resource-cards/function-dark"
     aria-hidden="true"
     class="resource-card__icon themed-image"></div>
    <h3 class="resource-card__title">
      Build a product discount function
    </h3>
    <p class="resource-card__description">Create a new &quot;Volume discount&quot; that offers a percentage off when customers purchase more than the minimum quantity of a product.</p>
  </a>
</div>

<div>
  <a class="resource-card" href="/docs/apps/build/discounts/build-ui-extension" data-theme-mode="">
    <div class="resource-card__indicator-container"><img
     src="/assets/resource-cards/blocks"
     data-alt-src="/assets/resource-cards/blocks-dark"
     aria-hidden="true"
     class="resource-card__icon themed-image"></div>
    <h3 class="resource-card__title">
      Build a discount function with an Admin UI extension
    </h3>
    <p class="resource-card__description">Create a discount with an Admin UI extension that allows merchants to create discounts and apply them to orders.</p>
  </a>
</div>

<div>
  <a class="resource-card" href="/docs/apps/build/discounts/build-ui-with-remix" data-theme-mode="">
    <div class="resource-card__indicator-container"><img
     src="/assets/resource-cards/remix"
     data-alt-src="/assets/resource-cards/remix-dark"
     aria-hidden="true"
     class="resource-card__icon themed-image"></div>
    <h3 class="resource-card__title">
      Build a discount UI with Remix
    </h3>
    <p class="resource-card__description">Create a discount UI with Remix that allows merchants to create discounts apply them to orders.</p>
  </a>
</div>

<div>
  <a class="resource-card" href="/docs/apps/build/discounts/build-discounts-allocator" data-theme-mode="">
    <div class="resource-card__indicator-container"><img
     src="/assets/resource-cards/function"
     data-alt-src="/assets/resource-cards/function-dark"
     aria-hidden="true"
     class="resource-card__icon themed-image"></div>
    <h3 class="resource-card__title">
      Build a discounts allocator function
    </h3>
    <p class="resource-card__description">Create a discounts allocator function that uses metafields to define custom allocation logic for discounts at the order and cart levels.</p>
  </a>
</div>

</div>



## Developer tools and resources

<div class="resource-card-grid">
  <div>
  <a class="resource-card" href="/docs/apps/build/cli-for-apps" data-theme-mode="">
    <div class="resource-card__indicator-container"><img
     src="/assets/resource-cards/cli"
     data-alt-src="/assets/resource-cards/cli-dark"
     aria-hidden="true"
     class="resource-card__icon themed-image"></div>
    <h3 class="resource-card__title">
      Shopify CLI
    </h3>
    <p class="resource-card__description">A command-line tool for building Shopify apps.</p>
  </a>
</div></p>

<p><div>
  <a class="resource-card" href="/docs/api/functions/reference/product-discounts/graphql" data-theme-mode="">
    <div class="resource-card__indicator-container"><img
     src="/assets/resource-cards/graphql"
     data-alt-src="/assets/resource-cards/graphql-dark"
     aria-hidden="true"
     class="resource-card__icon themed-image"></div>
    <h3 class="resource-card__title">
      Product Discount API reference
    </h3>
    <p class="resource-card__description">Consult the GraphQL reference for the Product Discount API.</p>
  </a>
</div>
</div>


## Migrating from scripts to functions


If you want to migrate an existing [line item script](https://help.shopify.com/manual/checkout-settings/script-editor/shopify-scripts) to Shopify Functions, then you can use the following mappings:

| Shopify Scripts method | Description | Shopify Functions object | Additional context |
|------------------------|-------------|--------------------------|-------------------|
| `change_line_price` | Applies a discount to a cart line such as a loyalty discount on a product by specifying a new reduced price, and a message either set by the developer or the merchant in the Function's configuration. | [Discount](/docs/api/functions/reference/discount/graphql/cartlinesdiscountsgeneraterunresult) | Apply [order discounts](/docs/api/functions/reference/discount/graphql/common-objects/orderdiscountcandidatetarget) or [product discounts](/docs/api/functions/reference/discount/graphql/common-objects/productdiscountcandidatetarget) by specifying the [OrderDiscountCandidateValue](/docs/api/functions/reference/discount/graphql/common-objects/orderdiscountcandidatevalue) or [ProductDiscountCandidateValue](/docs/api/functions/reference/discount/graphql/common-objects/productdiscountcandidatevalue) (`percentage` or `fixedAmount` off), and an optional message. |
| `split` | Splits a product into multiple lines so that you can apply discounts to partial quantities. For example, if a customer has five t-shirts in their cart, you can apply a discount to only two items while keeping the other three at full price | [Discount](/docs/api/functions/reference/discount/graphql/cartlinesdiscountsgeneraterunresult) | Use the optional `quantity` field in the [`ProductDiscountCandidateTarget`](/docs/api/functions/reference/discount/graphql/common-objects/productdiscountcandidatetarget) object to limit the number of units the discount may be applied to. |
| `change_properties` | Adds or changes a line item property | Not available | Refer to [applyAttributeChange](/docs/api/checkout-ui-extensions/latest/apis) in the checkout UI extensions API to apply attribute changes. |
| `reject` | Disallows a discounts code from being applied at checkout | Not available | Use a [Discount](/docs/api/functions/reference/discount/graphql/cartlinesdiscountsgeneraterunresult) function that contains the necessary logic. For example, you can use conditions to exclude a discount from applying, such as preventing a discount code when cart value is below $50 or when specific products are in the cart.  |




## Limitations and considerations

- Input `cart.deliveryGroups` is always an empty array for this function.
- Active automatic app discounts using Shopify Functions are applicable for all [Shopify sales channels](https://help.shopify.com/manual/online-sales-channels) that use Shopify Checkout, including the [Online Store](https://help.shopify.com/manual/online-store) and [Shopify Point Of Sale (POS)](https://help.shopify.com/manual/sell-in-person).


## Next steps

- Learn how to create discount apps that use [Shopify Discount Functions](/docs/apps/build/discounts).