Apply Promo Code
ApplyPromoCode Mutation
This mutation applies a promo code to an existing cart and recalculates the cart totals, including discounts. Itβs designed to be used from custom landing pages or checkout flows where you control the promo input.
Use Casesβ
- Landing page promo fields: Allow customers to enter a promo code before redirecting to checkout.
- Automatic campaign codes: Auto-apply a code based on campaign/UTM parameters.
- Re-engagement flows: Apply discount codes to carts recovered from abandoned sessions.
Headersβ
You should keep using the same sessionid header used for cart creation and updates:
{
"sessionid": "Session_3f6a0f1d-9c4a-4f3e-8f4b-1a2b3c4d5e6f"
}
The cartId in the variables should belong to this session.
Input Parametersβ
$storeId: ID!β The store in which the cart lives.$cartId: ID!β The target cart (Cart_...).$code: String!β The promo/coupon code to apply (e.g.SUMMER-2025).
Response Structureβ
Returns the updated Cart with:
id,sessionId,status,cartStepβ Cart metadata.promoCodeβ Applied promo code details (e.g.code).cartErrorsβ List of errors if the code is invalid or cannot be applied:codeβ Error code fromCheckoutServiceErrorCodes.params.messageβ Human-readable error message (if provided).
receiptβ Updated monetary breakdown:subtotalβ Cart subtotal before discounts.discountβ Total discount amount from the promo and any other discounts.shippingβ Shipping amount.taxβ Tax amount.totalβ Final payable amount.
Example Variablesβ
{
"storeId": "Store_cm84j35iy02m001i89iiu2cts",
"cartId": "Cart_d8f8ce2f-681e-4554-93b7-230e0b34a151",
"code": "SUMMER-2025"
}
Implementation Notesβ
- Call
ApplyPromoCodeafter you have a validcartId(for example afterAddToCartorReplaceCartItems+GetCart). - If the mutation returns
cartErrors, show the message to the customer and avoid redirecting to checkout until resolved. - After a successful apply, you can re-call
GetCartor rely on the returnedCartto display updated totals.
GraphQL Endpointβ
https://graphql.wuilt.com
Operation: ApplyPromoCodeβ
Try It Outβ
Queryβ
Query Variables
1
2
3
4
5
Note: Make sure to change the storeId with your store ID. For guidance on how to get your store ID, reference the Store ID guide.
Authenticationβ
To use this query, you will need an API key. Click the "API Key" button in the navigation bar to enter your credentials.