Order Discount Function API overview
The Order Discount API enables you to create a new type of discount that is applied to all merchandise in the cart.
Example use cases
Anchor link to section titled "Example use cases"- Money off the order subtotal. For example, $5 off the order subtotal.
- Money off products on an order. For example, 20% off all products on the order.
- Tiered discount by spend. For example, spend $100 get 10% off all products.
Developer tools and resources
Anchor link to section titled "Developer tools and resources"Migrating from scripts to functions
Anchor 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 |
---|---|---|---|
change_line_price |
Applies a discount to a product | Product discount or Order discount | |
split |
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. |
change_properties |
Adds or changes a line item property | Not available | Refer to applyAttributeChange in the checkout targets API. |
reject |
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. |
Limitations and considerations
Anchor link to section titled "Limitations and considerations"All plans: Stores on any plan can use public apps that are distributed through the Shopify App Store and contain Shopify Functions.
Shopify Plus: Only stores on a Shopify Plus plan can use custom apps that contain Shopify Function APIs.
- Learn how to use Shopify Functions by building a discounts experience.