Skip to content

Apply Coupon

About

The applyCoupon mutation applies a promotional coupon code to a shopping cart. Use this mutation to:

  • Apply discount codes to reduce cart total
  • Enable promo/coupon code functionality
  • Implement "Apply Coupon" features on cart page
  • Validate coupon eligibility
  • Display discount calculations
  • Support promotional campaigns

This mutation validates coupon code, checks eligibility conditions, and recalculates cart totals with applied discount.

Authentication

This mutation supports both authenticated customers and guest users:

  • Authenticated customers: Provide a valid customer authentication token in the Authorization header. Obtain this token via the Customer Login API.
  • Guest users: Provide the Guest Cart Token cartToken obtained from the Create Cart mutation.
Authorization: Bearer <accessToken>

Arguments

ArgumentTypeDescription
couponCodeString!Promotional coupon code to apply.

Possible Returns

FieldTypeDescription
applyCouponCoupon!Return coupon and cart related values.
applyCoupon.idStringid of the cart.
applyCoupon.discountAmountFloatTotal discount from all applied coupons.
applyCoupon.grandTotalFloat!Recalculated cart total with discount.
errors[ErrorMessage!]Validation errors if application failed.

Released under the MIT License.