applyRewardPointsToCart mutation

Magento Commerce only

The content on this page is for Magento Commerce only. Learn more

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, Magento applies the entire reward points balance. Otherwise, Magento 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

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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
mutation {
  applyRewardPointsToCart(cartId: "8k0Q4MpH2IGahWrTRtqM61YV2MtLPApz")
  {
    cart {
      items {
        quantity
        product {
          sku
          name
          price_range {
            maximum_price {
              final_price {
                currency
                value
              }
            }
          }
        }
      }
      applied_reward_points {
        money {
          currency
          value
        }
        points
      }
      prices {
        grand_total {
          currency
          value
        }
        applied_taxes {
          amount {
            currency
            value
          }
        }
      }
    }
  }
}

Response:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{
  "data": {
    "applyRewardPointsToCart": {
      "cart": {
        "items": [
          {
            "quantity": 1,
            "product": {
              "sku": "WJ04",
              "name": "Ingrid Running Jacket",
              "price_range": {
                "maximum_price": {
                  "final_price": {
                    "currency": "USD",
                    "value": 84
                  }
                }
              }
            }
          }
        ],
        "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
              }
            }
          ]
        }
      }
    }
  }
}

Input attributes

The applyRewardPointsToCart mutation requires the cart_id attribute.

Attribute Data Type Description
cart_id String! The unique ID that identifies the customer’s cart

Output attributes

The ApplyRewardPointsToCartOutput object contains the Cart object.

Attribute Data Type Description
cart Cart! Describes the contents of the specified shopping cart

Cart object

Attribute Data Type Description
applied_coupon AppliedCoupon Deprecated. Use applied_coupons instead
applied_coupons [AppliedCoupon] An array of AppliedCoupon objects. Each object contains the code text attribute, which specifies the coupon code
applied_gift_cards [AppliedGiftCard] An array of AppliedGiftCard objects. An AppliedGiftCard object contains the code text attribute, which specifies the gift card code. applied_gift_cards is a Commerce-only attribute, defined in the GiftCardAccountGraphQl module
applied_reward_points RewardPointsAmount The amount of reward points applied to the cart
applied_store_credit AppliedStoreCredit Contains store credit information applied to the cart. applied_store_credit is a Commerce-only attribute, defined in the CustomerBalanceGraphQl module
available_gift_wrappings [GiftWrapping]! The list of available gift wrapping options for the cart
available_payment_methods [AvailablePaymentMethod] Available payment methods
billing_address BillingCartAddress Contains the billing address specified in the customer’s cart
email String The customer’s email address
gift_message GiftMessage A gift message added to the cart
gift_receipt_included Boolean! Indicates if the customer requested a gift receipt for the cart
gift_wrapping GiftWrapping The selected gift wrapping for the cart
id ID! The ID of the cart
is_virtual Boolean! Indicates whether the cart contains only virtual products
items [CartItemInterface] Contains the items in the customer’s cart
prices CartPrices Contains subtotals and totals
printed_card_included Boolean! Indicates if the customer requested a printed card for the cart
selected_payment_method SelectedPaymentMethod Selected payment method
shipping_addresses [ShippingCartAddress]! Contains one or more shipping addresses
total_quantity Float! Total Quantity of products in the cart

Cart query output provides more information about the Cart object.