> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # ApplyDiscountToCheckout # Package: rewards # Namespace: LoyaltyCheckoutExchange # Method link: https://dev.wix.com/docs/api-reference/crm/loyalty-program/rewards/checkout-discount/apply-discount-to-checkout.md ## Permission Scopes: Manage Loyalty: SCOPE.DC-LOYALTY.MANAGE-LOYALTY ## Introduction Applies a discount to a checkout. You can apply one of the following discounts, which are exchanged for loyalty points: `reward`, `loyaltyCoupon`, or `referralReward`. --- ## REST API ### Schema ``` Method: applyDiscountToCheckout Description: Applies a discount to a checkout. You can apply one of the following discounts, which are exchanged for loyalty points: `reward`, `loyaltyCoupon`, or `referralReward`. URL: https://www.wixapis.com/v1/loyalty-checkout-discount Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: checkoutId Method parameters: param name: checkoutId | type: checkoutId | description: GUID of the checkout to apply the discount to. | required: true - ONE-OF: - name: reward | type: Reward | description: Unredeemed loyalty reward discount. - name: id | type: string | description: GUID of the loyalty reward to be used for this discount. - name: pointsToSpend | type: integer | description: Number of points to spend for this reward. For example, if the reward is 10 points = $1, then 35 points would give a $3.50 discount. >**Note:** Only relevant when using a flexible type reward. Depending on how your loyalty program is set up, there may be a minimum number of points you must spend. - name: revision | type: number | description: Revision number, which increments by 1 each time a reward is updated. To prevent conflicting changes, the current `revision` must be passed when updating a reward. - name: loyaltyCoupon | type: LoyaltyCoupon | description: Loyalty coupon discount. - name: id | type: string | description: GUID of the loyalty coupon to be used for this discount. - name: revision | type: number | description: Revision of the coupon object. Incremented by 1 each time the coupon object is updated. Pass the latest `revision` when updating to prevent conflicting changes. - name: referralReward | type: ReferralReward | description: Referral reward discount. - name: id | type: string | description: Referral reward discount GUID. - name: revision | type: number | description: Revision of the referral object. Incremented by 1 each time the referral object is updated. Pass the latest `revision` when updating to prevent conflicting changes. Return type: ApplyDiscountToCheckoutResponse - name: discount | type: LoyaltyCheckoutDiscount | description: The applied loyalty checkout discount. - ONE-OF: - name: rewardId | type: string | description: GUID of the loyalty reward used for this discount. - name: loyaltyCouponId | type: string | description: GUID of the loyalty coupon used for this discount. - name: referralRewardId | type: string | description: GUID of the referral reward used for this discount. - name: id | type: string | description: Loyalty checkout discount GUID. - name: checkoutId | type: string | description: GUID of the checkout this discount is applied to. - name: status | type: DiscountStatus | description: Current status of the discount. - enum: - UNKNOWN: Status is unknown or not specified. - APPLIED: Discount has been applied to the checkout. - IN_PROGRESS: Discount application is in progress. - COMPLETED: Discount has been successfully completed. - REFUNDED: Discount has been refunded. - FAILED_TO_REFUND: Attempt to refund the discount failed. - REFUNDED_DUE_TO_TIMEOUT: Discount was refunded due to a timeout. - REFUNDED_DUE_TO_MANUAL_DISCOUNT_REMOVAL: Discount was refunded due to manual removal. - SCHEDULED_FOR_REFUND: Discount is scheduled for refund. - UNUSED: Discount wasn't used. - name: discountType | type: DiscountType | description: The type of discount applied. - enum: - UNKNOWN: Discount type is unknown or not specified. - DISCOUNT_AMOUNT: A discount from a flexible reward. - LOYALTY_COUPON: A discount from a redeemed loyalty program coupon. - COUPON_REWARD: A discount from a coupon reward that hasn't yet been redeemed. - REFERRAL_REWARD: A discount from a referral reward. ``` ### Examples ### Apply Discount To Checkout ```curl curl -X POST \ 'https://www.wixapis.com/loyalty-checkout-exchange/v1/loyalty-checkout-discount' \ -H 'Authorization: ' \ -H 'Content-Type: application/json' \ -d '{ "checkoutId": "0c4c3398-7d64-4513-b3ed-e8033e2c28d6", "reward": { "id": "00000000-0000-0000-0001-000000000000", "revision": "1", "pointsToSpend": 10 } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.rewards.LoyaltyCheckoutExchange.applyDiscountToCheckout(checkoutId, options) Description: Applies a discount to a checkout. You can apply one of the following discounts, which are exchanged for loyalty points: `reward`, `loyaltyCoupon`, or `referralReward`. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: checkoutId Method parameters: param name: checkoutId | type: string | description: GUID of the checkout to apply the discount to. | required: true param name: options | type: ApplyDiscountToCheckoutOptions none | required: true - ONE-OF: - required: true - name: reward | type: Reward | description: Unredeemed loyalty reward discount. - name: _id | type: string | description: GUID of the loyalty reward to be used for this discount. - name: pointsToSpend | type: integer | description: Number of points to spend for this reward. For example, if the reward is 10 points = $1, then 35 points would give a $3.50 discount. >**Note:** Only relevant when using a flexible type reward. Depending on how your loyalty program is set up, there may be a minimum number of points you must spend. - name: revision | type: number | description: Revision number, which increments by 1 each time a reward is updated. To prevent conflicting changes, the current `revision` must be passed when updating a reward. - name: loyaltyCoupon | type: LoyaltyCoupon | description: Loyalty coupon discount. - name: _id | type: string | description: GUID of the loyalty coupon to be used for this discount. - name: revision | type: number | description: Revision of the coupon object. Incremented by 1 each time the coupon object is updated. Pass the latest `revision` when updating to prevent conflicting changes. - name: referralReward | type: ReferralReward | description: Referral reward discount. - name: _id | type: string | description: Referral reward discount GUID. - name: revision | type: number | description: Revision of the referral object. Incremented by 1 each time the referral object is updated. Pass the latest `revision` when updating to prevent conflicting changes. Return type: PROMISE - name: discount | type: LoyaltyCheckoutDiscount | description: The applied loyalty checkout discount. - ONE-OF: - name: rewardId | type: string | description: GUID of the loyalty reward used for this discount. - name: loyaltyCouponId | type: string | description: GUID of the loyalty coupon used for this discount. - name: referralRewardId | type: string | description: GUID of the referral reward used for this discount. - name: _id | type: string | description: Loyalty checkout discount GUID. - name: checkoutId | type: string | description: GUID of the checkout this discount is applied to. - name: status | type: DiscountStatus | description: Current status of the discount. - enum: - UNKNOWN: Status is unknown or not specified. - APPLIED: Discount has been applied to the checkout. - IN_PROGRESS: Discount application is in progress. - COMPLETED: Discount has been successfully completed. - REFUNDED: Discount has been refunded. - FAILED_TO_REFUND: Attempt to refund the discount failed. - REFUNDED_DUE_TO_TIMEOUT: Discount was refunded due to a timeout. - REFUNDED_DUE_TO_MANUAL_DISCOUNT_REMOVAL: Discount was refunded due to manual removal. - SCHEDULED_FOR_REFUND: Discount is scheduled for refund. - UNUSED: Discount wasn't used. - name: discountType | type: DiscountType | description: The type of discount applied. - enum: - UNKNOWN: Discount type is unknown or not specified. - DISCOUNT_AMOUNT: A discount from a flexible reward. - LOYALTY_COUPON: A discount from a redeemed loyalty program coupon. - COUPON_REWARD: A discount from a coupon reward that hasn't yet been redeemed. - REFERRAL_REWARD: A discount from a referral reward. ``` ### Examples ### applyDiscountToCheckout ```javascript import { checkoutExchange } from '@wix/loyalty'; async function applyDiscountToCheckout(checkoutId,options) { const response = await checkoutExchange.applyDiscountToCheckout(checkoutId,options); }; ``` ### applyDiscountToCheckout (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { checkoutExchange } from '@wix/loyalty'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { checkoutExchange }, // Include the auth strategy and host as relevant }); async function applyDiscountToCheckout(checkoutId,options) { const response = await myWixClient.checkoutExchange.applyDiscountToCheckout(checkoutId,options); }; ``` ---