Skip to main content

Redeeming Loyalty Rewards

NOTE: These mutations and queries will only work when used with a valid customer ID and apiKey which should be received during user authentication.

to redeem a reward the process is relatively similar to a discount. NOTE: A reward cannot be redeemed alongside a discount code.

Get list of customer rewards

query GetRewards {
customer_rewards(
where: {customer: {id: {_eq: "a01ae086-dc25-4ae3-851f-01a4c6edd915"}, merchant: {id: {_eq: "2ba090b2-d4dc-4fd1-ba5c-9e0b73586673"}}}, archived_at: {_is_null: true}, reward: {archived_at: {_is_null: true}}, redeemed_at: {_is_null: true}}
) {
id
redeemed_at
required_quantity
reward {
redeem_reward_message
description
name
reward_value
reward_value_type
reward_type
product_ids
required_quantity
loyalty_card_id
loyalty_card {
name
image
description
ends_at
merchant {
slug
}
all_stores_enabled
store_ids
}
}
}
}

Response:

{
"data": {
"customer_rewards": [
{
"id": "b88ec30d-ede6-44f3-b631-79ec13bed1f3",
"redeemed_at": null,
"required_quantity": 9,
"reward": {
"redeem_reward_message": "REWARD, REDEEMED. Congratulations you've redeemed a free coffee!",
"description": "Claim any coffee Free, excludes cold drinks. and make this longer",
"name": "1 Free Coffee let's make this a bit long",
"reward_value": 100,
"reward_value_type": "percentage",
"reward_type": "product",
"product_ids": [
"5bd53ab3-7098-4a7f-b82e-da83272b6aa4",
"1c17533f-dc05-4a44-9d7e-c372ac704b1a",
"1b517808-7164-4a10-8ac5-73a88a4016a0",
"190478eb-9be2-4a5a-8759-2c85d9998b64",
"1f38ee0f-5f6f-49e3-8664-b3f4ff5cae34",
"fe7e1cad-90d5-4136-a9af-318af22c2c92",
"7f6ed8c5-1500-4c23-a68f-6e0f60c3c2b4",
"d0c3816a-3d63-44ec-bed6-1cc671b51ffc",
"076fb68f-42ad-4837-8678-4e2ea0e07a2c",
"8cb159d9-dc76-4159-af0e-5fc6a7fef54b"
],
"required_quantity": 9,
"loyalty_card_id": "74c7479b-9051-4de9-bc25-baa242acfb1d",
"loyalty_card": {
"name": "Origin Loyalty Card",
"image": "origin.png?63806270389",
"description": "Collect stamps and earn rewards just making this longer for testing Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem",
"ends_at": null,
"merchant": {
"slug": "origincoffee"
},
"all_stores_enabled": false,
"store_ids": [
"1dc13cfa-b411-433c-b58a-0ef5866c391a"
]
}
}
},
{
"id": "70aeeab0-31fe-4d23-808b-7c252ea449c9",
"redeemed_at": null,
"required_quantity": 15,
"reward": {
"redeem_reward_message": "DOUGHNUT REDEEMED",
"description": null,
"name": "Free Doughnut",
"reward_value": 100,
"reward_value_type": "percentage",
"reward_type": "product",
"product_ids": [
"cbf43771-e13b-465f-b59d-51888e121f2e"
],
"required_quantity": 15,
"loyalty_card_id": "74c7479b-9051-4de9-bc25-baa242acfb1d",
"loyalty_card": {
"name": "Origin Loyalty Card",
"image": "origin.png?63806270389",
"description": "Collect stamps and earn rewards just making this longer for testing Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem",
"ends_at": null,
"merchant": {
"slug": "origincoffee"
},
"all_stores_enabled": false,
"store_ids": [
"1dc13cfa-b411-433c-b58a-0ef5866c391a"
]
}
}
}
]
}
}

Apply reward discount to cart

Use this mutation:

mutation ApplyRewardDiscount($customerRewardId: ID!, $cartId: ID!) {
applyRewardDiscount(customerRewardId: $customerRewardId, cartId: $cartId) {
type
value
discountCode
totalDiscount
discountId
}
}

example variables:

{
"customerRewardId": "b88ec30d-ede6-44f3-b631-79ec13bed1f3",
"cartId": "7fed53a7-9b58-4be0-9578-16148c8f7697"
}

example response:

{
"data": {
"applyRewardDiscount": {
"discountCode": "QFXY4R",
"discountId": "94515047-e4cd-4ea2-9185-375c3ec9d772",
"totalDiscount": "4.50",
"type": "percentage",
"value": "100"
}
}
}

Error response:

{
"data": {
"applyRewardDiscount": null
},
"errors": [
{
"locations": [
{
"column": 0,
"line": 2
}
],
"message": "Discount is not applicable to the items in your cart",
"path": [
"applyRewardDiscount"
]
}
]
}

When rewards are redeemed

Rewards do not class as redeemed until the users order has been accepted but the API will not accept an attempt to redeem the same reward twice.