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
13 changes: 9 additions & 4 deletions src/_data/toc/graphql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,14 @@ 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
edition: ee-only
exclude_versions: ["2.3"]

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

Expand All @@ -255,6 +256,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,17 +5,21 @@ 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! | Whether the customer requested a gift receipt 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! | Whether 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
`gift_wrapping` | GiftWrapping | The selected gift wrapping for the cart

[AppliedCoupon]: {{page.baseurl}}/graphql/queries/cart.html#AppliedCoupon
[AppliedGiftCard]: {{page.baseurl}}/graphql/queries/cart.html#AppliedGiftCard
Expand Down
7 changes: 7 additions & 0 deletions src/_includes/graphql/customer-orders-output.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ Attribute | Data type | Description
`comments` | [[CommentItem](#CommentItem)] | Comments on the order
`created_at` | String | Deprecated. Use the `order_date` attribute instead
`credit_memos` | [[CreditMemo](#CreditMemo)] | Contains a list of credit memos for the order
`gift_receipt_included` | Boolean! | Indicates whether the customer requested a gift receipt for the order
`grand_total` | Float | Deprecated. Use the `totals.grand_total` attribute instead
`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
Expand All @@ -55,6 +57,7 @@ Attribute | Data type | Description
`order_date` | String! | The date the order was placed
`order_number` | String! | Deprecated. Use the `number` attribute instead
`payment_methods` | [[PaymentMethod](#PaymentMethod)] | Payment details for the order
`printed_card_included` | Boolean! | Indicates whether 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 @@ -158,6 +161,10 @@ Attribute | Data type | Description
`amount` | Money! | The amount of the discount
`label` | String! | A description of the discount

### GiftWrapping object {#GiftWrapping}

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

#### Invoice attributes {#Invoice}

The `Invoice` object provides details about a customer invoice.
Expand Down
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
182 changes: 182 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,182 @@
---
group: graphql
title: setGiftOptionsOnCart mutation
ee_only: true
---

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

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.
15 changes: 15 additions & 0 deletions src/guides/v2.4/graphql/queries/cart.md
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ Attribute | Data Type | Description
`applied_taxes` | [[CartTaxItem]](#CartTaxItem) | An array containing the names and amounts of taxes applied to the item
`discount` | CartDiscount | Deprecated. Use `discounts` instead
`discounts` | [Discount] | An array containing all discounts applied to the cart
`gift_options` | [GiftOptionsPrices](#GiftOptionsPrices) | The list of prices for the selected gift options
`grand_total` | Money | The total, including discounts, taxes, shipping, and other fees
`subtotal_excluding_tax` | Money | Subtotal without taxes
`subtotal_including_tax` | Money | Subtotal with taxes
Expand Down Expand Up @@ -758,6 +759,20 @@ Attribute | Data Type | Description
`message` | String! | The gift message text
`to` | String! | Identifies the recipient

### GiftOptionsPrices object {#GiftOptionsPrices}

The `GiftOptionsPrices` object can contain the following attributes.

Attribute | Data Type | Description
--- | --- | ---
`gift_wrapping_for_items` | Money | The price of the gift wrapping for all individual order items
`gift_wrapping_for_order` | Money | The price of the gift wrapping for the whole order
`printed_card` | Money | The price of the printed card

### GiftWrapping object {#GiftWrapping}

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

### RewardPointsAmount {#RewardPointsAmount}

The `RewardPointsAmount` object must contain the following attributes.
Expand Down
11 changes: 11 additions & 0 deletions src/guides/v2.4/graphql/queries/store-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,25 @@ The following query returns enumeration values that indicate the store's fixed p

## Output attributes

The `StoreConfig` object can contain the following attributes.

Attribute | Data Type | Description | Default or example value
--- | --- | --- | ---
`absolute_footer` | String | Contains scripts that must be included in the HTML before the closing `<body>` tag | null
`allow_gift_wrapping_on_order` | String | Indicates whether a gift wrapping can be added for the entire order. Possible values: 1 (Yes) and 0 (No) | 1
`allow_gift_wrapping_on_order_items` | String | Indicates whether a gift wrapping can be added for individual order items. Possible values: 1 (Yes) and 0 (No) | 1
`allow_gift_receipt` | String | Indicates whether the gift sender has the option to send a gift receipt. Possible values: 1 (Yes) and 0 (No) | 1
`allow_items` | String | Allows gift messages for order items. Possible values: 1 (Yes) and 0 (No). <br/>Configuration path: sales/gift_options/allow_items | 0
`allow_order` | String | Allows gift messages at the order level. Possible values: 1 (Yes) and 0 (No). <br/>Configuration path: sales/gift_options/allow_order | 0
`allow_printed_card` | String | Indicates whether a printed card can accompany an order. Possible values: 1 (Yes) and 0 (No) | 1
`autocomplete_on_storefront` | Boolean | Enable autocomplete on login and forgot password forms. <br/>Configuration path: customer/password/autocomplete_on_storefront | true
`base_currency_code` | String | The code representing the currency in which Magento processes all payment transactions | `USD`
`base_link_url` | String | A fully-qualified URL that is used to create relative links to the `base_url` | `http://magentohost.example.com/`
`base_media_url` | String | The fully-qualified URL that specifies the location of user media files | `http://magentohost.example.com/pub/media/`
`base_static_url` | String | The fully-qualified URL that specifies the location of static view files | `http://magentohost.example.com/pub/static/`
`base_url` | String | The store's fully-qualified base URL | `http://magentohost.example.com/`
`cart_gift_wrapping` | String | Indicates whether gift wrapping prices are displayed on the Shopping Cart page. Possible values: 1 (Yes) and 0 (No) | 1
`cart_printed_card` | String | Indicates whether printed card prices are displayed on the Shopping Cart page. Possible values: 1 (Yes) and 0 (No) | 1
`catalog_default_sort_by` | String | The default sort order of the search results list | `position`
`category_fixed_product_tax_display_setting` | [FixedProductTaxDisplaySettings](#FixedProductTaxDisplaySettings) | Corresponds to the **Display Prices In Product Lists** field. It indicates how Fixed Product Tax information is displayed on category pages | FPT_DISABLED
`category_url_suffix` | String | The suffix applied to category pages, such as `.htm` or `.html` | `.html`
Expand Down Expand Up @@ -291,11 +299,14 @@ Attribute | Data Type | Description | Default or example value
`minimum_password_length` | String | The minimum number of characters required for a valid password. <br/>Configuration path: customer/password/minimum_password_length | 6
`no_route` | String | Contains the URL of the default page that you want to appear when if a 404 “Page not Found” error occurs | `cms/noroute/index`
`payment_payflowpro_cc_vault_active` | String | Payflow Pro vault status | `0` (inactive) or `1` (active)
`printed_card_price` | String | The default price of a printed card that accompanies an order | 10
`product_fixed_product_tax_display_setting` | [FixedProductTaxDisplaySettings](#FixedProductTaxDisplaySettings) | Corresponds to the **Display Prices On Product View Page** field. It indicates how Fixed Product Taxes information is displayed on product pages | FPT_DISABLED
`product_url_suffix` | String | The suffix applied to product pages, such as `.htm` or `.html` | `.html`
`required_character_classes_number` | String | The number of different character classes required in a password (lowercase, uppercase, digits, special characters). <br/>Configuration path: customer/password/required_character_classes_number | 2
`root_category_id` | Int | The ID of the root category | 2
`sales_fixed_product_tax_display_setting` | [FixedProductTaxDisplaySettings](#FixedProductTaxDisplaySettings) | Corresponds to the **Display Prices In Sales Modules** field. It indicates how Fixed Product Taxes information is displayed on cart, checkout, and order pages | FPT_DISABLED
`sales_gift_wrapping` | String | Indicates whether gift wrapping prices are displayed on the Orders page. Possible values: 1 (Yes) and 0 (No) | 1
`sales_printed_card` | String | Indicates whether printed card prices are displayed on the Orders page. Possible values: 1 (Yes) and 0 (No) | 1
`secure_base_link_url` | String | A secure fully-qualified URL that is used to create relative links to the `base_url` | `https://magentohost.example.com/`
`secure_base_media_url` | String | The secure fully-qualified URL that specifies the location of user media files | `https://magentohost.example.com/pub/media/`
`secure_base_static_url` | String | The secure fully-qualified URL that specifies the location of static view files | `https://magentohost.example.com/pub/static/`
Expand Down