Frontend API
Methods to apply and remove gift cards from the cart.
Use to apply a gift card code to the cart. A cart can have multiple gift card codes applied at once. Codes are not case-sensitive.
Returns the updated cart object if the gift card code is valid. Otherwise, it returns a validation error.
await swell.cart.applyGiftcard('BUYS SFX4 BMZH YY7N')
Use to remove a gift card from the cart; pass the id of the corresponding entry in cart.giftcards.
await swell.cart.removeGiftcard('5c15505200c7d14d851e51af')
Methods to apply and remove gift cards from the cart.
Apply a gift card
Use to apply a gift card to an account order. Returns the updated cart object if the gift card code is valid. Otherwise, it returns a validation error.
The parameters for this query are code (required), _locale, and _currency.
mutation {
applyGiftcard(code: "LPESSJKX6MKB6UMJ") {
accountId
grandTotal
giftcards {
id
code
amount
}
}
}Remove a gift card
Use to remove a gift card from an account order. Returns the updated cart object.
The parameters for this mutation are giftcardId (required), _locale, and _currency.
mutation {
removeGiftcard(giftcardId: "61d4bbbad38cb5013273b062") {
accountId
grandTotal
giftcards {
id
code
amount
}
}
}