Add a discount code using setDiscount
You can now apply a discount code to the cart using the existing
setDiscount method. It accepts a
discount_code key in addition to
discount_code is provided, other fields will be ignored. If no code is provided,
setDiscount expects at least an
type being optional.
||String||The discount code should match the exact code defined on Shopify admin on the Discounts page.|
||Number|| The discount amount to be applied to the
||String|| A description of the discount being applied. Default:
||String|| The discount type to apply to the subtotal of the cart. Valid values:
When a discount code is provided to
setDiscount, Shopify POS will validate that code to determine if it can be applied to the cart. If the code can't be applied, an invalid code error will be returned.
In addition, attempting to call
discount_code but no
amount on older Shopify POS versions will return an error. If a
amount is provided, older Shopify POS clients will ignore the code and parse the
amount as expected.
Older versions of Shopify POS will not support the ability to
setDiscount with a code. This means that it is up to you, the developer, to gracefully support older Shopify POS clients.
In order to determine whether the merchant's version of Shopify POS supports
setDiscount with a code, we recommend calling
setDiscount with only
discount_code. If that version of Shopify POS does not support adding discounts using a code, an error will be returned. We then recommend calling
setDiscount again with
description. For example:
If you have any other questions, please contact us.