Shopify
shopify.dev › docs › api › functions › latest › discount
Discount Function API
The Discount Function API provides a unified schema for creating Function extensions. A single Function processes one discount (either code-based or automatic), but can apply savings across three discount classes: product, order, and shipping.
Shopify
shopify.dev › docs › api › checkout-ui-extensions › latest › apis › discounts
Discounts
The API for interacting with discounts.
Videos
05:31
How to Create Discount Code & Price Rule Through Shopify Rest Admin ...
Shopify Tutorial - Create a Discount Shopify Function - YouTube
Shopify Functions - New Discount Function | Discount API - YouTube
Build a Custom Discount app with Shopify Admin API
30:03
Build a Custom Discount app with Shopify Admin API - YouTube
Shopify Tutorial - Build a UI For Discount Shopify Functions - YouTube
Shopify
shopify.dev › docs › api › functions › reference › product-discounts
Discount Function API - Shopify.dev
The Discount Function API provides a unified schema for creating Function extensions. A single Function processes one discount (either code-based or automatic), but can apply savings across three discount classes: product, order, and shipping.
Yepcode
yepcode.io › recipes › rest-api-to-shopify-discount-codes
REST API to Shopify discount codes | YepCode Recipes | Code snippets for solving common problems
More info at https://yepcode.io/docs/processes/team-variables // TODO: Add your http credential with Shopify information: // baseUrl: https://your-development-store.myshopify.com/admin/api/2022-04 // HTTP Headers: { "X-Shopify-Access-Token": "your-access-token" } this.httpClient = axios.create({ baseURL: yepcode.env.SHOPIFY_BASE_URL, headers: { "X-Shopify-Access-Token": yepcode.env.SHOPIFY_ACCESS_TOKEN, }, }); } async consume(item) { // TODO: Customize your request checking the API documentation: // https://shopify.dev/api/admin-rest/2022-04/resources/discountcode#post-price-rules-price-rule-id-discount-codes await this.httpClient.post( "/price_rules/<price-rule-id>/discount_codes.json", { discount_code: { code: item.code + "OFF", }, } ); } async close() {} }
Shopify
shopify.dev › docs › api › admin-rest › latest › resources › discountcode
DiscountCode
The discount_code_id path parameter is the ID of the discount code to retrieve for the associated price rule. ... curl -X GET "https://your-development-store.myshopify.com/admin/api/2025-10/price_rules/507328175/discount_codes/507328175.json" \
Shopify
shopify.dev › docs › api › checkout-ui-extensions › 2024-10 › apis › discounts
Discounts API - Shopify.dev
The API for interacting with discounts.
Shopify
shopify.dev › docs › api › functions › reference › product-discounts › graphql
Product Discount API reference - Shopify.dev
The Discount Function API provides a unified schema for creating Function extensions. A single Function processes one discount (either code-based or automatic), but can apply savings across three discount classes: product, order, and shipping.
Shopify
shopify.dev › docs › api › functions › reference › order-discounts
About the Order Discount Function API - Shopify.dev
The Discount Function API provides a unified schema for creating Function extensions. A single Function processes one discount (either code-based or automatic), but can apply savings across three discount classes: product, order, and shipping.
Top answer 1 of 3
5
$shop = ShopifyApp::shop();
if( $shopSettings->discount_id == '' || $shopSettings->discount_id == null || $shopSettings->discount_id == undefined ) {
$price_rule = $shop->api()->rest(
'POST',
'/admin/price_rules.json',
[
"price_rule" => [
"title" => "SUMMERSALE10OFF",
"target_type" => "line_item",
"target_selection" => "all",
"allocation_method" => "across",
"value_type" => "percentage",
"value" => "-"+request('discount_percentage'),
"customer_selection" => "all",
"starts_at" => "2017-01-19T17:59:10Z"
]
]
);
$shopSettings->price_rule_id = $price_rule->body->price_rule->id;
$discount_code = $shop->api()->rest(
'POST',
'/admin/price_rules/'.$price_rule->body->price_rule->id.'/discount_codes.json',
[
"discount_code" => [
"code" => $price_rule->body->price_rule->title
]
]
);
$shopSettings->discount_id = $discount_code->body->discount_code->id;
} else if( request('discount_percentage') && request('discount_type') == "percentage" ) {
$price_rule = $shop->api()->rest(
'POST',
'/admin/price_rules/'.$shopSettings->price_rule_id.'.json',
[
"price_rule" => [
"value" => "-"+request('discount_percentage')
]
]
);
}
2 of 3
4
To all those coming here, Shopify has recently developed an endpoint to create discount codes and price rules.
Price Rule
Discount Code
Shopify
shopify.dev › docs › api › functions › reference › discounts-allocator
About the Discounts Allocator Function API - Shopify.dev
Use the Discounts Allocator Function API to provide custom logic that determines how discounts should be calculated in a cart.
Shopify
shopify.dev › docs › apps › build › discounts
About discounts
These classes determine which part of the cart the discount Function targets, enabling Shopify to correctly calculate and apply the appropriate price reduction during checkout. Discount classes are used to define the effect of a discount on a cart. The discount's discountClasses field determines which Function targets will be executed during checkout. App discounts built with the Discount Function API can return operations that use Order and Product discount classes in their CartLinesDiscountsGenerateRunResult and the Shipping class in CartDeliveryOptionsDiscountsGenerateRunResult.
Oscprofessionals
oscprofessionals.com › home › shopify apps › what are the different discount apis for shopify apps?
What Are the Different Discount APIs for Shopify Apps
December 31, 2024 - Contact us now and get your store up and running fast! The Shipping Discount API available via Shopify Apps allows merchants to create discounts for shipping rates applied at checkout.
Address 34, Mantri House, 34, Cement Rd, Om Sai Nagar, Shivaji Nagar, 440010, Nagpur
GitHub
github.com › ramdhanishivam › discount-function-app
GitHub - ramdhanishivam/discount-function-app: Shopify Functions API - Javascript App for Discount
Shopify Functions API - Javascript App for Discount - GitHub - ramdhanishivam/discount-function-app: Shopify Functions API - Javascript App for Discount
Author ramdhanishivam