applyRewardPointsToCart mutation
The applyRewardPointsToCart
mutation applies reward points to the customer's cart. You cannot specify a quantity of reward points. If the reward points balance is less than the cart total, the application applies the entire reward points balance. Otherwise, the application applies as many reward points needed to bring the total to 0. Fractional reward points are discarded.
Use the removeRewardPointsFromCart
mutation to undo the results of the applyRewardPointsToCart
mutation.
Syntax
mutation: applyRewardPointsToCart(cartId: ID!): ApplyRewardPointsToCartOutput
Reference
The applyRewardPointsToCart
reference provides detailed information about the types and fields defined in this mutation.
Example usage
The following example applies $5 to the cart. In this example, the exchange rate is defined as 25 reward points equals $5.
Request:
Copied to your clipboardmutation {applyRewardPointsToCart(cartId: "8k0Q4MpH2IGahWrTRtqM61YV2MtLPApz"){cart {itemsV2 {items {quantityproduct {skunameprice_range {maximum_price {final_price {currencyvalue}}}}}total_countpage_info {page_sizecurrent_pagetotal_pages}}applied_reward_points {money {currencyvalue}points}prices {grand_total {currencyvalue}applied_taxes {amount {currencyvalue}}}}}}
Response:
Copied to your clipboard{"data": {"applyRewardPointsToCart": {"cart": {"itemsV2": {"items": [{"quantity": 1,"product": {"sku": "WJ04","name": "Ingrid Running Jacket","price_range": {"maximum_price": {"final_price": {"currency": "USD","value": 84}}}}}],"total_count": 1,"page_info": {"page_size": 20,"current_page": 1,"total_pages": 1}},"applied_reward_points": {"money": {"currency": "USD","value": 5},"points": 25},"prices": {"grand_total": {"currency": "USD","value": 90.93},"applied_taxes": [{"amount": {"currency": "USD","value": 6.93}}]}}}}}
Errors
Error | Description |
---|---|
Required parameter "cart_id" is missing | The mutation does not contain a cart_id argument. |
Could not find a cart with ID "XXX" | The specified cart_id value does not exist in the quote_id_mask table. |