This repository was archived by the owner on Nov 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
GraphQL: Add coverage for gift wrapping and messages #7745
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f7be4fa
GraphQL: Add coverage for gift wrapping
keharper 46ea064
GraphQL: Add coverage for gift wrapping and messages
keharper 828c0b5
gift message updates
keharper 20d6985
Update src/_includes/graphql/cart-object-24.md
keharper af74b59
Remove ee-only designations
keharper eb85ce0
Merge branch '2.4.1-develop' of github.com:magento/devdocs into kh_gi…
keharper 2b4898d
fix merge conflict
keharper f9a3a5a
Add attribute to updateCartItems
keharper 5721640
revert changes made in wrong file
keharper 69479bf
Apply suggestions from code review
keharper be93b03
Fix link
keharper 0cac71e
Merge branch 'kh_giftwrap' of github.com:magento/devdocs into kh_gift…
keharper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
The `GiftMessage` object can contain the following attributes. | ||
|
||
Attribute | Data Type | Description | ||
--- | --- | --- | ||
`from` | String! | The name of the gift sender | ||
`message` | String! | The text of the gift message | ||
`to` | String! | The name of the gift recipient |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
The `GiftWrapping` object can contain the following attributes. | ||
|
||
Attribute | Data Type | Description | ||
--- | --- | --- | ||
`design` | String! | The name of the gift wrapping design | ||
`id` | ID! | The unique identifier for the gift wrapping option | ||
`image` | [GiftWrappingImage](#GiftWrappingImage) | The preview image for the gift wrapping option | ||
`price` | Money! | The price of the gift wrapping option | ||
|
||
### GiftWrappingImage object {#GiftWrappingImage} | ||
|
||
The `GiftWrappingImage` object must contain the following attributes. | ||
|
||
Attribute | Data Type | Description | ||
--- | --- | --- | ||
`label` | String! | The label of the gift wrapping preview image | ||
`url` | String! | The URL of the gift wrapping preview image |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
--- | ||
group: graphql | ||
title: setGiftOptionsOnCart mutation | ||
--- | ||
|
||
The `setGiftOptionsOnCart` mutation allows the buyer to set the following gift options on the cart level: | ||
|
||
* Gift messages | ||
* Gift wrapping | ||
* A gift receipt to accompany the order | ||
* A printed card to accompany the order | ||
|
||
{:.bs-callout-info} | ||
Gift messages are a feature of {{site.data.var.ce}}. All other gift options require {{site.data.var.ee}}. | ||
|
||
To remove a gift message, set the `gift_message` object to null. To remove gift wrapping, set the `gift_wrapping_id` attribute to null. | ||
|
||
Use the [updateCartItems mutation]({{page.baseurl}}/graphql/mutations/update-cart-items.html) to set gift messages and gift wrapping on individual items. | ||
|
||
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). | ||
|
||
* `allow_gift_receipt` | ||
* `allow_gift_wrapping_on_order` | ||
* `allow_printed_card` | ||
* `cart_gift_wrapping` | ||
* `cart_printed_card` | ||
* `printed_card_price` | ||
* `sales_gift_wrapping` | ||
* `sales_printed_card` | ||
|
||
Gift wrapping is available for simple, configurable, bundle products as well as physical gift cards. | ||
|
||
## Syntax | ||
|
||
`mutation: {setGiftOptionsOnCart(input: SetGiftOptionsOnCartInput): SetGiftOptionsOnCartOutput}` | ||
|
||
## Example usage | ||
|
||
The following example adds a gift message, gift wrapping, and a gift receipt to the cart. | ||
|
||
**Request:** | ||
|
||
```graphql | ||
mutation { | ||
setGiftOptionsOnCart( | ||
input: { | ||
cart_id: "8k0Q4MpH2IGahWrTRtqM61YV2MtLPApz" | ||
gift_message: { | ||
to: "Alex" | ||
from: "Veronica" | ||
message: "Happy Birthday!" | ||
} | ||
gift_wrapping_id: "Mg==" | ||
gift_receipt_included: true | ||
printed_card_included: false | ||
} | ||
) { | ||
cart { | ||
id | ||
gift_message { | ||
to | ||
from | ||
message | ||
} | ||
gift_wrapping { | ||
id | ||
} | ||
gift_receipt_included | ||
printed_card_included | ||
items { | ||
quantity | ||
prices { | ||
price { | ||
value | ||
currency | ||
} | ||
} | ||
} | ||
prices { | ||
gift_options { | ||
gift_wrapping_for_order { | ||
value | ||
currency | ||
} | ||
} | ||
grand_total { | ||
value | ||
currency | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
**Response:** | ||
|
||
```json | ||
{ | ||
"data": { | ||
"setGiftOptionsOnCart": { | ||
"cart": { | ||
"id": "8k0Q4MpH2IGahWrTRtqM61YV2MtLPApz", | ||
"gift_message": { | ||
"to": "Alex" | ||
"from": "Veronica" | ||
"message": "Happy Birthday!" | ||
} | ||
"gift_wrapping": { | ||
"id": "2" | ||
}, | ||
"gift_receipt_included": true, | ||
"printed_card_included": false, | ||
"items": [ | ||
{ | ||
"quantity": 1, | ||
"prices": { | ||
"price": { | ||
"value": 32, | ||
"currency": "USD" | ||
} | ||
} | ||
}, | ||
{ | ||
"quantity": 1, | ||
"prices": { | ||
"price": { | ||
"value": 84, | ||
"currency": "USD" | ||
} | ||
} | ||
} | ||
], | ||
"prices": { | ||
"gift_options": { | ||
"gift_wrapping_for_order": { | ||
"value": 7, | ||
"currency": "USD" | ||
} | ||
}, | ||
"grand_total": { | ||
"value": 132.57, | ||
"currency": "USD" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Input attributes | ||
|
||
The `SetGiftOptionsOnCartInput` object can contain the following attributes: | ||
|
||
Attribute | Data Type | Description | ||
--- | --- | --- | ||
`cart_id` | String! | The unique ID that identifies the shopper's cart | ||
`gift_message` | [GiftMessageInput](#GiftMessageInput) | Gift message details for the cart | ||
`gift_receipt_included` | Boolean! | Indicates whether the customer requested a gift receipt for the cart | ||
`gift_wrapping_id` | ID | The unique identifier of the gift wrapping to be used for the cart | ||
`printed_card_included` | Boolean! | Indicates whether the customer requested a printed card for the cart | ||
|
||
### GiftMessageInput {#GiftMessageInput} | ||
|
||
The `GiftMessageInput` object must contain the following attributes: | ||
|
||
Attribute | Data Type | Description | ||
--- | --- | --- | ||
`from` | String! | The name of the gift sender | ||
`message` | String! | The text of the gift message | ||
`to` | String! | The name of the gift recipient | ||
|
||
## Output attributes | ||
|
||
The `SetGiftOptionsOnCartOutput` object contains the `Cart` object. | ||
|
||
Attribute | Data Type | Description | ||
--- | --- | --- | ||
`cart` |[Cart!](#CartObject) | Describes the contents of the specified shopping cart | ||
|
||
### Cart object {#CartObject} | ||
|
||
{% include graphql/cart-object-24.md %} | ||
|
||
[Cart query output]({{page.baseurl}}/graphql/queries/cart.html#cart-output) provides more information about the `Cart` object. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.