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

GraphQL: Add coverage for gift wrapping and messages #7745

Merged
merged 12 commits into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/_data/toc/graphql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,13 @@ pages:
- label: sendEmailToFriend mutation
url: /graphql/mutations/send-email-to-friend.html

- label: subscribeEmailToNewsletter mutation
url: /graphql/mutations/subscribe-email-to-newsletter.html
exclude_versions: ["2.3"]

- label: setBillingAddressesOnCart mutation
url: /graphql/mutations/set-billing-address.html

- label: setGiftOptionsOnCart mutation
url: /graphql/mutations/set-gift-options.html
exclude_versions: ["2.3"]

- label: setGuestEmailOnCart mutation
url: /graphql/mutations/set-guest-email.html

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

- label: subscribeEmailToNewsletter mutation
url: /graphql/mutations/subscribe-email-to-newsletter.html
exclude_versions: ["2.3"]

- label: updateCartItems mutation
url: /graphql/mutations/update-cart-items.html

Expand Down
4 changes: 4 additions & 0 deletions src/_includes/graphql/cart-object-24.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ Attribute | Data Type | Description
`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
`applied_reward_points`| [`RewardPointsAmount`][RewardPointsAmount] | The amount of reward points applied to the cart
`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
`available_gift_wrappings` | [GiftWrapping]! | The list of available gift wrapping options for the cart
`available_payment_methods` | [[AvailablePaymentMethod]][AvailablePaymentMethod] | Available payment methods
`billing_address` | [BillingCartAddress][BillingCartAddress] | Contains the billing address specified in the customer's cart
`email` | String | The customer's email address
`gift_message` | [GiftMessage][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]][CartItemInterface] | Contains the items in the customer's cart
`prices` | [CartPrices][CartPrices] | Contains subtotals and totals
`printed_card_included` | Boolean! | Indicates if the customer requested a printed card for the cart
`selected_payment_method` | [SelectedPaymentMethod][SelectedPaymentMethod] | Selected payment method
`shipping_addresses` | [[ShippingCartAddress]][ShippingCartAddress]! | Contains one or more shipping addresses
`total_quantity` | Float! | Total Quantity of products in the cart
Expand Down
34 changes: 23 additions & 11 deletions src/_includes/graphql/customer-orders-output.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,18 @@ Attribute | Data type | Description
`created_at` | String | Deprecated. Use the `order_date` attribute instead
`credit_memos` | [[CreditMemo](#CreditMemo)] | Contains a list of credit memos for the order
`grand_total` | Float | Deprecated. Use the `totals.grand_total` attribute instead
`gift_message` | [GiftMessage](#GiftMessage) | The entered gift message for the order
`gift_receipt_included` | Boolean! | Indicates if the customer requested a gift receipt for the order
`gift_wrapping` | [GiftWrapping](#GiftWrapping) | The selected gift wrapping for the order
`id` | ID! | Unique identifier for the order
`increment_id` | String | Deprecated. Use the `id` attribute instead
`invoices` | [[Invoice](#Invoice)]! | Contains a list of invoices for the order
`items` | [[OrderItemInterface](#OrderItemInterface)] | An array containing the items purchased in this order
`number` | String! | The order number
`order_date` | String! | The date the order was placed
`order_number` | String! | Deprecated. Use the `number` attribute instead
`payment_methods` | [[OrderPaymentMethod](#OrderPaymentMethod)] | Payment details for the order
`payment_methods` | [[PaymentMethod](#PaymentMethod)] | Payment details for the order
`printed_card_included` | Boolean! | Indicates if the customer requested a printed card for the order
`shipments` | [[OrderShipment](#OrderShipment)] | Shipment list for the order
`shipping_address` | [OrderAddress](#OrderAddress) | Shipping address for the order
`shipping_method` | String | Shipping method for the order
Expand Down Expand Up @@ -227,6 +231,14 @@ Attribute | Data type | Description
--- | --- | ---
`gift_card` | [GiftCardItem](#GiftCardItem) | Selected gift card properties for a shipped item

### GiftMessage attributes {#GiftMessage}

{% include graphql/gift-message.md %}

### GiftWrapping attributes {#GiftWrapping}

{% include graphql/gift-wrapping.md %}

#### Invoice attributes {#Invoice}

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

#### OrderPaymentMethod attributes {#OrderPaymentMethod}

The OrderPaymentMethod data type contains details about the payment method used to pay for the order.

Attribute | Data type | Description
--- | --- | ---
`additional_data` | [[KeyValue](#KeyValue)] | Additional data per payment method type
`name` | String! | The label that describes the payment method
`type` | String! | The payment method code that indicates how the order was paid for

#### OrderShipment attributes {#OrderShipment}

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

#### PaymentMethod attributes {#PaymentMethod}

The PaymentMethod data type contains details about the payment method used to pay for the order.

Attribute | Data type | Description
--- | --- | ---
`additional_data` | [[KeyValue](#KeyValue)] | Additional data per payment method type
`name` | String! | The label that describes the payment method
`type` | String! | The payment method code that indicates how the order was paid for

#### RewardPoints attributes {#RewardPoints}

The `RewardPoints` object provides details about the customer's reward points balance, history, and related information.
Expand Down
7 changes: 7 additions & 0 deletions src/_includes/graphql/gift-message.md
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
17 changes: 17 additions & 0 deletions src/_includes/graphql/gift-wrapping.md
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
186 changes: 186 additions & 0 deletions src/guides/v2.4/graphql/mutations/set-gift-options.md
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.
28 changes: 19 additions & 9 deletions src/guides/v2.4/graphql/mutations/update-cart-items.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
---
group: graphql
title: updateCartItems mutation
redirect from:
- /guides/v2.3/graphql/reference/quote-update-cart-items.html
---

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.
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.

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

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

### UpdateCartItemsInput object {#UpdateCartItemsInput}
### UpdateCartItemsInput attributes {#UpdateCartItemsInput}

The `UpdateCartItemsInput` object must contain the following attributes:
The `UpdateCartItemsInput` object must contain the following attributes.

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

### CartItemUpdateInput object {#CartItemUpdateInput}
### CartItemUpdateInput attributes {#CartItemUpdateInput}

The `CartItemUpdateInput` object may contain the following attributes:
The `CartItemUpdateInput` object can contain the following attributes.

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

### CustomizableOptionInput object {#CustomizableOptionInputSimple}
### CustomizableOptionInput attributes {#CustomizableOptionInputSimple}

The `CustomizableOptionInput` object must contain the following attributes:
The `CustomizableOptionInput` object must contain the following attributes.

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

### GiftMessageInput attributes {#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 `UpdateCartItemsOutput` object contains the `Cart` object.
Expand Down
Loading