-
-
Notifications
You must be signed in to change notification settings - Fork 313
Discounts
Joshua Harms edited this page Dec 20, 2023
·
1 revision
Developers can create a discount code with the DiscountService
. A merchant's customers can enter the discount code during the checkout process to redeem percentage-based, fixed amount, or free shipping discounts on a specific product, collection or order.
Discounts require a Shopify Plus subscription.
var service = new DiscountService(myShopifyUrl, shopAccessToken);
var discount = await service.CreateAsync(new Discount()
{
DiscountType = "fixed_amount",
Value = "10.00",
DiscountCode = "AuntieDot",
MinimumOrderAmount = "40.00",
});
var service = new DiscountService(myShopifyUrl, shopAccessToken);
var discount = await service.GetAsync(discountId):
var service = new DiscountService(myShopifyUrl, shopAccessToken);
var discounts = await service.ListAsync();
var service = new DiscountService(myShopifyUrl, shopAccessToken);
await service.DeleteAsync(discountId);
Discount codes can be disabled via that API, which makes them inactive and unusable until reenabled.
var service = new DiscountService(myShopifyUrl, shopAccessToken);
await service.DisableAsync(discountId);
Once disabled, a discount cannot be used by any customer until it's enabled.
var service = new DiscountService(myShopifyUrl, shopAccessToken);
await service.EnableAsync(discountId);