Product Discount API overview
The Product Discount API enables you to create a new type of discount that is applied to a particular product or product variant in the cart.
Example use casesAnchor link to section titled "Example use cases"
- Money off a product. For example, 20% off shirts.
- Money off a product variant. For example, $5 off blue shirts.
- 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.
Developer tools and resourcesAnchor link to section titled "Developer tools and resources"
Migrating from scripts to functionsAnchor link to section titled "Migrating from scripts to functions"
If you want to migrate an existing line item script to Shopify Functions, then you can use the following mappings:
|Shopify Scripts method||Description||Shopify Functions object||Additional context|
||Applies a discount to a product||Product discount or Order discount|
||Splits a product into multiple lines so that you can discount partial numbers||Product discount||Use a product variant to limit the number of times that you want to apply the discount.|
||Adds or changes a line item property||Not available||Refer to applyAttributeChange in the checkout extension points API.|
||Disallows a discounts code from being applied at checkout||Not available||Use a Product discount or Order discount function that contains the necessary logic. For example, you can use conditions to exclude a discount from applying.|
- Learn how to use Shopify Functions by building a discounts experience.