Shopify discount codes
A "use code SUMMER20" ad needs a real code at checkout. Hermoso creates it on your Shopify store, lists the codes you have and turns one off, and every answer is Shopify's own copy of the code, read back after the change. It works for a store that installed Hermoso from the Shopify App Store, and it costs no credits.
Create a code
create_shopify_discount_code makes a code for every customer and every product.
| Field | What it is |
|---|---|
code | Required. What customers type at checkout, with no spaces. |
percentOff or amountOff | One of the two. 20 is 20% off; an amount is in the store's currency. appliesOnEachItem: true takes a fixed amount off each item instead of the whole order. |
minSubtotal or minQuantity | Optional, one of the two: a minimum order amount or a minimum number of items. |
startsAt, endsAt | When the code works. It starts now unless you say otherwise, and has no end date unless you give one. |
usageLimit, oncePerCustomer | How many times it can be used in total, and whether each customer can use it once. |
A code works at the live checkout and every use is money off your sales, so the first call creates nothing: it describes the code. Call again with confirm: true to create it. Nothing you wrote is changed: a code with a space, 0% or more than 100%, or an end date in the past is refused with the reason.
List and turn off
list_shopify_discount_codes: the codes on the store, newest first, with what each takes off, its dates, its use limit, how many times it has been used and whether it is active, scheduled or expired. Filter withstatusor search the title. Shopify updates the use count in the background, so it can be a few minutes behind. Every kind of code is listed: amount off, buy X get Y, free shipping and codes made by another app. Dates are shown in your store's time zone.disable_shopify_discount_code: byidor bycode. The first call changes nothing and names the code;confirm: trueturns it off, and the answer is the status Shopify reports afterwards. Shopify keeps the code, so it can be switched back on in Shopify admin under Discounts.
The routes are POST /api/shopify/discount, GET /api/shopify/discounts and POST /api/shopify/discount/disable.
The permission
Discount codes need one more Shopify permission. A store that installed Hermoso before it was added is asked to approve it the next time the app is opened from the Shopify admin. Until then, these tools answer with that step, and nothing is created or changed.