Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit e0005c0

Browse files
authored
Merge pull request #7745 from magento/kh_giftwrap
GraphQL: Add coverage for gift wrapping and messages
2 parents 151c05f + 0cac71e commit e0005c0

File tree

9 files changed

+297
-28
lines changed

9 files changed

+297
-28
lines changed

src/_data/toc/graphql.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,13 @@ pages:
243243
- label: sendEmailToFriend mutation
244244
url: /graphql/mutations/send-email-to-friend.html
245245

246-
- label: subscribeEmailToNewsletter mutation
247-
url: /graphql/mutations/subscribe-email-to-newsletter.html
248-
exclude_versions: ["2.3"]
249-
250246
- label: setBillingAddressesOnCart mutation
251247
url: /graphql/mutations/set-billing-address.html
252248

249+
- label: setGiftOptionsOnCart mutation
250+
url: /graphql/mutations/set-gift-options.html
251+
exclude_versions: ["2.3"]
252+
253253
- label: setGuestEmailOnCart mutation
254254
url: /graphql/mutations/set-guest-email.html
255255

@@ -265,6 +265,10 @@ pages:
265265
- label: setShippingMethodsOnCart mutation
266266
url: /graphql/mutations/set-shipping-method.html
267267

268+
- label: subscribeEmailToNewsletter mutation
269+
url: /graphql/mutations/subscribe-email-to-newsletter.html
270+
exclude_versions: ["2.3"]
271+
268272
- label: updateCartItems mutation
269273
url: /graphql/mutations/update-cart-items.html
270274

src/_includes/graphql/cart-object-24.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@ Attribute | Data Type | Description
55
`applied_gift_cards` | [[`AppliedGiftCard`]][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
66
`applied_reward_points`| [`RewardPointsAmount`][RewardPointsAmount] | The amount of reward points applied to the cart
77
`applied_store_credit` | [`AppliedStoreCredit`][AppliedStoreCredit] | Contains store credit information applied to the cart. `applied_store_credit` is a Commerce-only attribute, defined in the CustomerBalanceGraphQl module
8+
`available_gift_wrappings` | [GiftWrapping]! | The list of available gift wrapping options for the cart
89
`available_payment_methods` | [[AvailablePaymentMethod]][AvailablePaymentMethod] | Available payment methods
910
`billing_address` | [BillingCartAddress][BillingCartAddress] | Contains the billing address specified in the customer's cart
1011
`email` | String | The customer's email address
1112
`gift_message` | [GiftMessage][GiftMessage] | A gift message added to the cart
13+
`gift_receipt_included` | Boolean! | Indicates if the customer requested a gift receipt for the cart
14+
`gift_wrapping` | GiftWrapping | The selected gift wrapping for the cart
1215
`id` | ID! | The ID of the cart
1316
`is_virtual` | Boolean! | Indicates whether the cart contains only virtual products
1417
`items` | [[CartItemInterface]][CartItemInterface] | Contains the items in the customer's cart
1518
`prices` | [CartPrices][CartPrices] | Contains subtotals and totals
19+
`printed_card_included` | Boolean! | Indicates if the customer requested a printed card for the cart
1620
`selected_payment_method` | [SelectedPaymentMethod][SelectedPaymentMethod] | Selected payment method
1721
`shipping_addresses` | [[ShippingCartAddress]][ShippingCartAddress]! | Contains one or more shipping addresses
1822
`total_quantity` | Float! | Total Quantity of products in the cart

src/_includes/graphql/customer-orders-output.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,18 @@ Attribute | Data type | Description
4747
`created_at` | String | Deprecated. Use the `order_date` attribute instead
4848
`credit_memos` | [[CreditMemo](#CreditMemo)] | Contains a list of credit memos for the order
4949
`grand_total` | Float | Deprecated. Use the `totals.grand_total` attribute instead
50+
`gift_message` | [GiftMessage](#GiftMessage) | The entered gift message for the order
51+
`gift_receipt_included` | Boolean! | Indicates if the customer requested a gift receipt for the order
52+
`gift_wrapping` | [GiftWrapping](#GiftWrapping) | The selected gift wrapping for the order
5053
`id` | ID! | Unique identifier for the order
5154
`increment_id` | String | Deprecated. Use the `id` attribute instead
5255
`invoices` | [[Invoice](#Invoice)]! | Contains a list of invoices for the order
5356
`items` | [[OrderItemInterface](#OrderItemInterface)] | An array containing the items purchased in this order
5457
`number` | String! | The order number
5558
`order_date` | String! | The date the order was placed
5659
`order_number` | String! | Deprecated. Use the `number` attribute instead
57-
`payment_methods` | [[OrderPaymentMethod](#OrderPaymentMethod)] | Payment details for the order
60+
`payment_methods` | [[PaymentMethod](#PaymentMethod)] | Payment details for the order
61+
`printed_card_included` | Boolean! | Indicates if the customer requested a printed card for the order
5862
`shipments` | [[OrderShipment](#OrderShipment)] | Shipment list for the order
5963
`shipping_address` | [OrderAddress](#OrderAddress) | Shipping address for the order
6064
`shipping_method` | String | Shipping method for the order
@@ -227,6 +231,14 @@ Attribute | Data type | Description
227231
--- | --- | ---
228232
`gift_card` | [GiftCardItem](#GiftCardItem) | Selected gift card properties for a shipped item
229233

234+
### GiftMessage attributes {#GiftMessage}
235+
236+
{% include graphql/gift-message.md %}
237+
238+
### GiftWrapping attributes {#GiftWrapping}
239+
240+
{% include graphql/gift-wrapping.md %}
241+
230242
#### Invoice attributes {#Invoice}
231243

232244
The `Invoice` object provides details about a customer invoice.
@@ -358,16 +370,6 @@ Attribute | Data type | Description
358370
`label` | String! | The name of the option
359371
`value` | String! | The value of the option
360372

361-
#### OrderPaymentMethod attributes {#OrderPaymentMethod}
362-
363-
The OrderPaymentMethod data type contains details about the payment method used to pay for the order.
364-
365-
Attribute | Data type | Description
366-
--- | --- | ---
367-
`additional_data` | [[KeyValue](#KeyValue)] | Additional data per payment method type
368-
`name` | String! | The label that describes the payment method
369-
`type` | String! | The payment method code that indicates how the order was paid for
370-
371373
#### OrderShipment attributes {#OrderShipment}
372374

373375
Attribute | Data type | Description
@@ -393,6 +395,16 @@ Attribute | Data type | Description
393395
`total_shipping` | Money! | The shipping costs for the order
394396
`total_tax` | Money! | The amount of tax applied to the order
395397

398+
#### PaymentMethod attributes {#PaymentMethod}
399+
400+
The PaymentMethod data type contains details about the payment method used to pay for the order.
401+
402+
Attribute | Data type | Description
403+
--- | --- | ---
404+
`additional_data` | [[KeyValue](#KeyValue)] | Additional data per payment method type
405+
`name` | String! | The label that describes the payment method
406+
`type` | String! | The payment method code that indicates how the order was paid for
407+
396408
#### RewardPoints attributes {#RewardPoints}
397409

398410
The `RewardPoints` object provides details about the customer's reward points balance, history, and related information.

src/_includes/graphql/gift-message.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
The `GiftMessage` object can contain the following attributes.
2+
3+
Attribute | Data Type | Description
4+
--- | --- | ---
5+
`from` | String! | The name of the gift sender
6+
`message` | String! | The text of the gift message
7+
`to` | String! | The name of the gift recipient
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
The `GiftWrapping` object can contain the following attributes.
2+
3+
Attribute | Data Type | Description
4+
--- | --- | ---
5+
`design` | String! | The name of the gift wrapping design
6+
`id` | ID! | The unique identifier for the gift wrapping option
7+
`image` | [GiftWrappingImage](#GiftWrappingImage) | The preview image for the gift wrapping option
8+
`price` | Money! | The price of the gift wrapping option
9+
10+
### GiftWrappingImage object {#GiftWrappingImage}
11+
12+
The `GiftWrappingImage` object must contain the following attributes.
13+
14+
Attribute | Data Type | Description
15+
--- | --- | ---
16+
`label` | String! | The label of the gift wrapping preview image
17+
`url` | String! | The URL of the gift wrapping preview image
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
---
2+
group: graphql
3+
title: setGiftOptionsOnCart mutation
4+
---
5+
6+
The `setGiftOptionsOnCart` mutation allows the buyer to set the following gift options on the cart level:
7+
8+
* Gift messages
9+
* Gift wrapping
10+
* A gift receipt to accompany the order
11+
* A printed card to accompany the order
12+
13+
{:.bs-callout-info}
14+
Gift messages are a feature of {{site.data.var.ce}}. All other gift options require {{site.data.var.ee}}.
15+
16+
To remove a gift message, set the `gift_message` object to null. To remove gift wrapping, set the `gift_wrapping_id` attribute to null.
17+
18+
Use the [updateCartItems mutation]({{page.baseurl}}/graphql/mutations/update-cart-items.html) to set gift messages and gift wrapping on individual items.
19+
20+
These options are configured on the **Stores** > Configuration > **Sales** > **Sales** > **Gift Options** screen. To determine whether these options are enabled, specify these attributes in the [`storeConfig` query]({{page.baseurl}}/graphql/queries/store-config.html).
21+
22+
* `allow_gift_receipt`
23+
* `allow_gift_wrapping_on_order`
24+
* `allow_printed_card`
25+
* `cart_gift_wrapping`
26+
* `cart_printed_card`
27+
* `printed_card_price`
28+
* `sales_gift_wrapping`
29+
* `sales_printed_card`
30+
31+
Gift wrapping is available for simple, configurable, bundle products as well as physical gift cards.
32+
33+
## Syntax
34+
35+
`mutation: {setGiftOptionsOnCart(input: SetGiftOptionsOnCartInput): SetGiftOptionsOnCartOutput}`
36+
37+
## Example usage
38+
39+
The following example adds a gift message, gift wrapping, and a gift receipt to the cart.
40+
41+
**Request:**
42+
43+
```graphql
44+
mutation {
45+
setGiftOptionsOnCart(
46+
input: {
47+
cart_id: "8k0Q4MpH2IGahWrTRtqM61YV2MtLPApz"
48+
gift_message: {
49+
to: "Alex"
50+
from: "Veronica"
51+
message: "Happy Birthday!"
52+
}
53+
gift_wrapping_id: "Mg=="
54+
gift_receipt_included: true
55+
printed_card_included: false
56+
}
57+
) {
58+
cart {
59+
id
60+
gift_message {
61+
to
62+
from
63+
message
64+
}
65+
gift_wrapping {
66+
id
67+
}
68+
gift_receipt_included
69+
printed_card_included
70+
items {
71+
quantity
72+
prices {
73+
price {
74+
value
75+
currency
76+
}
77+
}
78+
}
79+
prices {
80+
gift_options {
81+
gift_wrapping_for_order {
82+
value
83+
currency
84+
}
85+
}
86+
grand_total {
87+
value
88+
currency
89+
}
90+
}
91+
}
92+
}
93+
}
94+
```
95+
96+
**Response:**
97+
98+
```json
99+
{
100+
"data": {
101+
"setGiftOptionsOnCart": {
102+
"cart": {
103+
"id": "8k0Q4MpH2IGahWrTRtqM61YV2MtLPApz",
104+
"gift_message": {
105+
"to": "Alex"
106+
"from": "Veronica"
107+
"message": "Happy Birthday!"
108+
}
109+
"gift_wrapping": {
110+
"id": "2"
111+
},
112+
"gift_receipt_included": true,
113+
"printed_card_included": false,
114+
"items": [
115+
{
116+
"quantity": 1,
117+
"prices": {
118+
"price": {
119+
"value": 32,
120+
"currency": "USD"
121+
}
122+
}
123+
},
124+
{
125+
"quantity": 1,
126+
"prices": {
127+
"price": {
128+
"value": 84,
129+
"currency": "USD"
130+
}
131+
}
132+
}
133+
],
134+
"prices": {
135+
"gift_options": {
136+
"gift_wrapping_for_order": {
137+
"value": 7,
138+
"currency": "USD"
139+
}
140+
},
141+
"grand_total": {
142+
"value": 132.57,
143+
"currency": "USD"
144+
}
145+
}
146+
}
147+
}
148+
}
149+
}
150+
```
151+
152+
## Input attributes
153+
154+
The `SetGiftOptionsOnCartInput` object can contain the following attributes:
155+
156+
Attribute | Data Type | Description
157+
--- | --- | ---
158+
`cart_id` | String! | The unique ID that identifies the shopper's cart
159+
`gift_message` | [GiftMessageInput](#GiftMessageInput) | Gift message details for the cart
160+
`gift_receipt_included` | Boolean! | Indicates whether the customer requested a gift receipt for the cart
161+
`gift_wrapping_id` | ID | The unique identifier of the gift wrapping to be used for the cart
162+
`printed_card_included` | Boolean! | Indicates whether the customer requested a printed card for the cart
163+
164+
### GiftMessageInput {#GiftMessageInput}
165+
166+
The `GiftMessageInput` object must contain the following attributes:
167+
168+
Attribute | Data Type | Description
169+
--- | --- | ---
170+
`from` | String! | The name of the gift sender
171+
`message` | String! | The text of the gift message
172+
`to` | String! | The name of the gift recipient
173+
174+
## Output attributes
175+
176+
The `SetGiftOptionsOnCartOutput` object contains the `Cart` object.
177+
178+
Attribute | Data Type | Description
179+
--- | --- | ---
180+
`cart` |[Cart!](#CartObject) | Describes the contents of the specified shopping cart
181+
182+
### Cart object {#CartObject}
183+
184+
{% include graphql/cart-object-24.md %}
185+
186+
[Cart query output]({{page.baseurl}}/graphql/queries/cart.html#cart-output) provides more information about the `Cart` object.

src/guides/v2.4/graphql/mutations/update-cart-items.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
---
22
group: graphql
33
title: updateCartItems mutation
4-
redirect from:
5-
- /guides/v2.3/graphql/reference/quote-update-cart-items.html
64
---
75

8-
The `updateCartItems` mutation allows you to replace the current quantity of one or more cart items with the specified quantities. It does not perform calculations to determine the quantity of cart items.
6+
The `updateCartItems` mutation allows you to modify items in the specified cart. You can also replace the current quantity of one or more cart items with the specified quantities. The mutation does not perform calculations to determine the quantity of cart items.
97

108
{:.bs-callout-info}
119
Setting the quantity to `0` removes an item from the cart.
@@ -91,31 +89,43 @@ mutation {
9189

9290
The `UpdateCartItemsInput` object is listed first. All child objects are listed in alphabetical order.
9391

94-
### UpdateCartItemsInput object {#UpdateCartItemsInput}
92+
### UpdateCartItemsInput attributes {#UpdateCartItemsInput}
9593

96-
The `UpdateCartItemsInput` object must contain the following attributes:
94+
The `UpdateCartItemsInput` object must contain the following attributes.
9795

9896
Attribute | Data Type | Description
9997
--- | --- | ---
10098
`cart_id` | String! | The unique ID that identifies the customer's cart
10199
`cart_items` | [CartItemUpdateInput!](#CartItemUpdateInput) | Contains the cart item IDs and quantity of each item
102100

103-
### CartItemUpdateInput object {#CartItemUpdateInput}
101+
### CartItemUpdateInput attributes {#CartItemUpdateInput}
104102

105-
The `CartItemUpdateInput` object may contain the following attributes:
103+
The `CartItemUpdateInput` object can contain the following attributes.
106104

107105
Attribute | Data Type | Description
108106
--- | --- | ---
109107
`cart_item_id` | Int! | The unique ID assigned when a customer places an item in the cart
110108
`customizable_options` | [CustomizableOptionInput!] | An array that defines customizable options for the product
109+
`gift_message` | [GiftMessageInput](#GiftMessageInput) | Gift message details for the cart item
110+
`gift_wrapping_id` | ID | The unique identifier of the gift wrapping to be used for the cart item
111111
`quantity` | Float | The new quantity of the item. A value of `0` removes the item from the cart
112112

113-
### CustomizableOptionInput object {#CustomizableOptionInputSimple}
113+
### CustomizableOptionInput attributes {#CustomizableOptionInputSimple}
114114

115-
The `CustomizableOptionInput` object must contain the following attributes:
115+
The `CustomizableOptionInput` object must contain the following attributes.
116116

117117
{% include graphql/customizable-option-input.md %}
118118

119+
### GiftMessageInput attributes {#GiftMessageInput}
120+
121+
The `GiftMessageInput` object must contain the following attributes.
122+
123+
Attribute | Data Type | Description
124+
--- | --- | ---
125+
`from` | String! | The name of the gift sender
126+
`message` | String! | The text of the gift message
127+
`to` | String! | The name of the gift recipient
128+
119129
## Output attributes
120130

121131
The `UpdateCartItemsOutput` object contains the `Cart` object.

0 commit comments

Comments
 (0)