attach-loyalty-reward Function

Attaches a loyalty reward to the cart.

Example

fetch('/s/api/v1/cart/loyalty/reward', {
	method: 'POST',
	headers: {
		'X-CSRF-TOKEN': 'csrf_token_from_csrf_meta_tag',
	},
	body: JSON.stringify({
		loyaltyAccountId: "5bcdb22f-0b57-4feb-af5a-d7f8ae33eb9f",
		loyaltyRewardTierId: "0534d095-9a58-427d-8e7a-0d28e5897b37",
		loyaltyRewardName: "$2.00 off one Breakfast sandwich",
		discountType: "FIXED_AMOUNT",
		discountScope: "LINE_ITEM",
		discountValue: 200,
		itemIds: [
			"YGXQM2QSBTXHBNBCT4GTTIPD"
		],
		orderId: "11ef1d135548d3a88c6b089e019fd17a"
	})
})
	.then((response) => ...);

You can use the Site Theme SDK instead of calling the Cart API directly. The SDK is intended to simplify cart actions.