From 33046d13ca9014756913ee7a819a2d7e64f15cf5 Mon Sep 17 00:00:00 2001 From: Kevin Harper Date: Mon, 13 May 2019 01:11:28 -0500 Subject: [PATCH 1/6] checkpoint --- _data/toc/graphql.yml | 28 +- _includes/graphql/cart-address-input.md | 12 + _includes/graphql/cart-item-input.md | 4 + _includes/graphql/cart-object.md | 18 + .../graphql/customizable-option-input.md | 4 + .../graphql/reference/quote-add-products.md | 320 ++++++ .../graphql/reference/quote-apply-discount.md | 216 ++++ .../graphql/reference/quote-create-cart.md | 73 ++ .../graphql/reference/quote-payment-method.md | 99 ++ .../graphql/reference/quote-place-order.md | 135 +++ .../graphql/reference/quote-set-addresses.md | 233 +++++ .../reference/quote-shipping-method.md | 116 +++ .../reference/quote-update-remove-products.md | 214 ++++ guides/v2.3/graphql/reference/quote.md | 968 +++++++++--------- 14 files changed, 1943 insertions(+), 497 deletions(-) create mode 100644 _includes/graphql/cart-address-input.md create mode 100644 _includes/graphql/cart-item-input.md create mode 100644 _includes/graphql/cart-object.md create mode 100644 _includes/graphql/customizable-option-input.md create mode 100644 guides/v2.3/graphql/reference/quote-add-products.md create mode 100644 guides/v2.3/graphql/reference/quote-apply-discount.md create mode 100644 guides/v2.3/graphql/reference/quote-create-cart.md create mode 100644 guides/v2.3/graphql/reference/quote-payment-method.md create mode 100644 guides/v2.3/graphql/reference/quote-place-order.md create mode 100644 guides/v2.3/graphql/reference/quote-set-addresses.md create mode 100644 guides/v2.3/graphql/reference/quote-shipping-method.md create mode 100644 guides/v2.3/graphql/reference/quote-update-remove-products.md diff --git a/_data/toc/graphql.yml b/_data/toc/graphql.yml index dff22fbbb42..1bb2a8f3722 100644 --- a/_data/toc/graphql.yml +++ b/_data/toc/graphql.yml @@ -87,7 +87,33 @@ pages: url: /graphql/reference/grouped-product.html - label: Quote endpoint - url: /graphql/reference/quote.html + children: + - label: Query a cart + url: /graphql/reference/quote.html + + - label: Create a cart + url: /graphql/reference/quote-create-cart.html + + - label: Add products to a cart + url: /graphql/reference/quote-add-products.html + + - label: Update and remove products + url: /graphql/reference/quote-update-remove-products.html + + - label: Manage coupons + url: /graphql/reference/quote-apply-discount.html + + - label: Set billing and shipping addresses + url: /graphql/reference/quote-set-addresses.html + + - label: Set shipping methods + url: /graphql/reference/quote-shipping-method.html + + - label: Set the payment method + url: /graphql/reference/quote-payment-method.html + + - label: Place an order + url: /graphql/reference/quote-place-order.html - label: Sales endpoint url: /graphql/reference/sales.html diff --git a/_includes/graphql/cart-address-input.md b/_includes/graphql/cart-address-input.md new file mode 100644 index 00000000000..dc182767944 --- /dev/null +++ b/_includes/graphql/cart-address-input.md @@ -0,0 +1,12 @@ +Attribute | Data Type | Description +--- | --- | --- +`city` | String! | The city specified for the billing or shipping address +`company` | String | The company specified for the billing or shipping address +`country_code` | String! | The country code and label for the billing or shipping address +`firstname` | String! | The customer's first name +`lastname` | String! | The customer's last name +`postcode` | String | The postal code for the billing or shipping address +`region` | String | The region code and label for the billing or shipping address +`save_in_address_book` | Boolean! | Specifies whether to save the address (`True`/`False`) +`street` | [String]! | An array containing the street for the billing or shipping address +`telephone` | String | The telephone number for the billing or shipping address \ No newline at end of file diff --git a/_includes/graphql/cart-item-input.md b/_includes/graphql/cart-item-input.md new file mode 100644 index 00000000000..ff44c8f8d1d --- /dev/null +++ b/_includes/graphql/cart-item-input.md @@ -0,0 +1,4 @@ +Attribute | Data Type | Description +--- | --- | --- +`quantity` | Float! | The quantity of the item to add to the cart +`sku` | String! | The sku of the product to be added to the cart \ No newline at end of file diff --git a/_includes/graphql/cart-object.md b/_includes/graphql/cart-object.md new file mode 100644 index 00000000000..d8152dc3157 --- /dev/null +++ b/_includes/graphql/cart-object.md @@ -0,0 +1,18 @@ +Attribute | Data Type | Description +--- | --- | --- +`applied_coupon` | [`AppliedCoupon`][AppliedCoupon] | The `AppliedCoupon` object contains the `code` text attribute, which specifies the coupon code +`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 +`items` | [CartItemInterface][CartItemInterface] | Contains the items in the customer's cart +`prices` | [CartPrices][CartPrices] | Contains subtotals and totals +`selected_payment_method` | [SelectedPaymentMethod][SelectedPaymentMethod] | Selected payment method +`shipping_addresses` | [ShippingCartAddress][ShippingCartAddress] | Contains one or more shipping addresses + +[AppliedCoupon]: {{page.baseurl}}/graphql/reference/quote.html#AppliedCoupon +[AvailablePaymentMethod]: {{page.baseurl}}/reference/quote.html#AvailablePaymentMethod +[BillingCartAddress]: {{page.baseurl}}/reference/quote.html#BillingCartAddress +[CartItemInterface]: {{page.baseurl}}/graphql/reference/quote.html#CartItemInterface +[CartPrices]: {{page.baseurl}}/graphql/reference/quote.html#CartPrices +[SelectedPaymentMethod]: {{page.baseurl}}/graphql/reference/quote.html#SelectedPaymentMethod +[ShippingCartAddress]: {{page.baseurl}}/graphql/reference/quote.html#AppliedShippingCartAddressCoupon diff --git a/_includes/graphql/customizable-option-input.md b/_includes/graphql/customizable-option-input.md new file mode 100644 index 00000000000..4ec894093cb --- /dev/null +++ b/_includes/graphql/customizable-option-input.md @@ -0,0 +1,4 @@ +Attribute | Data Type | Description +--- | --- | --- +`id` | Int! | A unique ID assigned to the customizable option +`value_string` | String! | A value assigned to the the customizable option \ No newline at end of file diff --git a/guides/v2.3/graphql/reference/quote-add-products.md b/guides/v2.3/graphql/reference/quote-add-products.md new file mode 100644 index 00000000000..a5d463731e2 --- /dev/null +++ b/guides/v2.3/graphql/reference/quote-add-products.md @@ -0,0 +1,320 @@ +--- +group: graphql +title: Add products to a cart +--- + +This topic describes how to add the following types of products to a cart: + +* Simple +* Virtual + +{:.bs-callout .bs-callout-info} +The mutation for [adding configurable products]({{page.baseurl}}/graphql/reference/configurable-product.html) is defined in the `ConfigurableProductGraphQl` module. + +## Add simple products + +To add a simple product to a cart, you must provide the cart ID, the SKU, and the quantity. You can also optionally provide customizable options. + +### Syntax + +`mutation; {addSimpleProductsToCart(input: AddSimpleProductsToCartInput): AddSimpleProductsToCartOutput}` + +### Example usage + +These examples show the minimal payload and a payload that includes customizable options. + +#### Add a simple product to a cart + +The following example adds a simple product to a cart. The response contains the entire contents of the customer's cart. + +**Request** + +```text +mutation { + addSimpleProductsToCart( + input: { + cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", + cart_items: [ + { + data: { + quantity: 1 + sku: "24-MB04" + } + } + ] + } + ) { + cart { + items { + id + product { + name + sku + } + quantity + } + } + } +} +``` + +**Response** + +```json +{ + "data": { + "addSimpleProductsToCart": { + "cart": { + "items": [ + { + "id": "13", + "product": { + "name": "Strive Shoulder Pack", + "sku": "24-MB04" + }, + "quantity": 1 + } + ] + } + } + } +} +``` + +#### Add a simple product with customizable options to a cart + +If a product has a customizable option, the option's value can be specified in the add to cart request. + +**Request** + +``` text +mutation { + addSimpleProductsToCart (input: { + cart_id: "nu31JXR9DaqbdVqFDGnqjrMJmUnT3mzB" + cart_items: { + data: { + sku: "simple" + quantity: 1 + }, + customizable_options: [ + { + id: 121 + value_string: "field value" + } + ] + } + }) { + cart { + items { + product { + name + } + quantity + + ... on SimpleCartItem { + customizable_options { + label + values { + value + } + } + } + } + } + } +} +``` + +**Response** + +```text +{ + "data": { + "addSimpleProductsToCart": { + "cart": { + "items": [ + { + "product": { + "name": "simple" + }, + "qty": 2, + "customizable_options": [ + { + "label": "Field Option", + "values": [ + { + "value": "field value" + } + ] + } + ] + } + ] + } + } + } +} +``` + +### Input attributes + +The top-level `AddSimpleProductsToCartInput` object is listed first. All child objects are listed in alphabetical order. + +#### AddSimpleProductsToCartInput object {#AddSimpleProductsToCartInput} + +The `AddSimpleProductsToCartInput` object must contain the following attributes: + +Attribute | Data Type | Description +--- | --- | --- +`cart_id` | String! | The unique ID that identifies the customer's cart +`cart_items` | SimpleProductCartItemInput! | Contains the cart item IDs and quantity of each item + +#### CartItemInput object + +The `CartItemInput` object must contain the following attributes: + +{% include graphql/customizable-option-input.md %} + +#### CustomizableOptionInput object + +The `CustomizableOptionInput` object must contain the following attributes: + +{% include graphql/customizable-option-input.md %} + +#### SimpleProductCartItemInput object + +The `SimpleProductCartItemInput` object must contain the following attributes: + +`customizable_options` |[CustomizableOptionInput] | An array that defines customizable options for the product +`data` | CartItemInput! | An object containing the `sku` and `quantity` of the product. + +### Output attributes + +The `AddSimpleProductsToCartOutput` object contains the `Cart` object. + +Attribute | Data Type | Description +--- | --- | --- +`cart` | Cart! | Describes the contents of the specified shopping cart. + +#### Cart object + +{% include graphql/cart-object.md %} + +## Add virtual products + +A virtual product represents a saleable item that is not physical, such as a membership, service, warranty, or subscription. + +### Syntax + +`mutation; {addVirtualProductsToCart(input: AddVirtualProductsToCartInput): AddVirtualProductsToCartOutput}` + +### Example usage + +The Luma sample data does not include any virtual products. The following example requires that you create a virtual product with the `sku` value Membership-Gold with a price of $49.99. + +**Request** + +```text + +mutation { + addVirtualProductsToCart( + input: { + cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", + cart_items: [ + { + data: { + quantity: 1 + sku: "Membership-Gold" + } + } + ] + } + ) { + cart { + items { + product { + name + } + quantity + } + prices { + grand_total { + value + currency + } + } + } + } +} +``` + +**Response** + +```json +{ + "data": { + "addVirtualProductsToCart": { + "cart": { + "items": [ + { + "product": { + "name": "Gold Membership" + }, + "quantity": 1 + } + ], + "prices": { + "grand_total": { + "value": 49.99, + "currency": "USD" + } + } + } + } + } +} +``` + +### Input attributes + +The top-level `AddVirtualProductsToCartInput` object is listed first. All child objects are listed in alphabetical order. + +#### AddVirtualProductsToCartInput object {#AddVirtualProductsToCartInput} + +The `AddVirtualProductsToCartInput` object must contain the following attributes: + +Attribute | Data Type | Description +--- | --- | --- +`cart_id` | String! | The unique ID that identifies the customer's cart +`cart_items` | VirtualProductCartItemInput! | Contains the cart item IDs and quantity of each item + +#### CartItemInput object + +The `CartItemInput` object must contain the following attributes: + +{% include graphql/cart-item-input.md %} + +#### CustomizableOptionInput object + +The `CustomizableOptionInput` object must contain the following attributes: + +{% include graphql/customizable-option-input.md %} + +#### VirtualProductCartItemInput object + +The `VirtualProductCartItemInput` object must contain the following attributes: + +`customizable_options` |[CustomizableOptionInput] | An array that defines customizable options for the product +`data` | CartItemInput! | An object containing the `sku` and `quantity` of the product. + +### Output attributes + +The `AddVirtualProductsToCartOutput` object contains the `Cart` object. + +Attribute | Data Type | Description +--- | --- | --- +`cart` | Cart! | Describes the contents of the specified shopping cart. + +#### Cart object + +{% include graphql/cart-object.md %} \ No newline at end of file diff --git a/guides/v2.3/graphql/reference/quote-apply-discount.md b/guides/v2.3/graphql/reference/quote-apply-discount.md new file mode 100644 index 00000000000..ca8f2facb34 --- /dev/null +++ b/guides/v2.3/graphql/reference/quote-apply-discount.md @@ -0,0 +1,216 @@ +--- +group: graphql +title: Manage coupons +--- + +You can use GraphQL to apply a coupon to a cart or remove a coupon from the same cart. + +## Apply a coupon to a cart + +The `applyCouponToCart` mutation applies a pre-defined coupon code to the specified cart. Valid coupon codes are defined in cart price rules. + +### Syntax + +`mutation: {applyCouponToCart(input: ApplyCouponToCartInput) {ApplyCouponToCartOutput}}` + +### Example usage + +The following example applies the coupon code `H2O` to the cart. For this coupon to be valid, the Affirm Water Bottle (`sku`: 24-UG06) must be in the cart. + +**Request** + +``` text +mutation { + applyCouponToCart( + input: { + cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", + coupon_code: "H20" + } + ) { + cart { + items { + product { + name + } + quantity + } + applied_coupon { + code + } + prices { + grand_total{ + value + currency + } + } + } + } +} +``` + +**Response** + +```json +{ + "data": { + "applyCouponToCart": { + "cart": { + "items": [ + { + "product": { + "name": "Gold Membership" + }, + "quantity": 2 + }, + { + "product": { + "name": "Strive Shoulder Pack" + }, + "quantity": 1 + }, + { + "product": { + "name": "Affirm Water Bottle " + }, + "quantity": 1 + } + ], + "applied_coupon": { + "code": "H20" + }, + "prices": { + "grand_total": { + "value": 134.08, + "currency": "USD" + } + } + } + } + } +} +``` + +### Input attributes + +The `applyCouponToCart` mutation requires the `cart_id` and `coupon_code`. + +#### ApplyCouponToCartInput object {#ApplyCouponToCartInput} + +The `ApplyCouponToCartInput` object must contain the following attributes: + +Attribute | Data Type | Description +--- | --- | --- +`cart_id` | String! | The unique ID that identifies the customer's cart +`coupon_code` | String! | A valid coupon code + + +### Output attributes + +The `ApplyCouponToCartOutput` object contains the `Cart` object. + +Attribute | Data Type | Description +--- | --- | --- +`cart` | Cart! | Describes the contents of the specified shopping cart. + +#### Cart object + +{% include graphql/cart-object.md %} + +## Remove a coupon from a cart + +The `removeCouponFromCart` mutation removes a previously-applied coupon from the cart. + +### Syntax + +`mutation: {removeCouponFromCart(input: RemoveCouponFromCartInput){ RemoveCouponFromCartOutput}}` + +### Example usage + +The following example removes a coupon from the cart. + +**Request** + +``` text +mutation { + removeCouponFromCart( + input: + { cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG" } + ) { + cart { + items { + product { + name + } + quantity + } + applied_coupon { + code + } + prices { + grand_total{ + value + currency + } + } + } + } +} +``` + +**Response** + +```json +{ + "data": { + "removeCouponFromCart": { + "cart": { + "items": [ + { + "product": { + "name": "Strive Shoulder Pack" + }, + "quantity": 1 + }, + { + "product": { + "name": "Affirm Water Bottle " + }, + "quantity": 1 + } + ], + "applied_coupon": null, + "prices": { + "grand_total": { + "value": 39, + "currency": "USD" + } + } + } + } + } +} +``` + +### Input attributes + +The `removeCouponFromCart` mutation requires the `cart_id` attribute. + +#### removeCouponFromCart object {#removeCouponFromCart} + +The `removeCouponFromCart` object must contain the following attributes: + +Attribute | Data Type | Description +--- | --- | --- +`cart_id` | String! | The unique ID that identifies the customer's cart + +### Output attributes + +The `removeCouponFromCart` object contains the `Cart` object. + +Attribute | Data Type | Description +--- | --- | --- +`cart` | Cart! | Describes the contents of the specified shopping cart. + +#### Cart object + +{% include graphql/cart-object.md %} diff --git a/guides/v2.3/graphql/reference/quote-create-cart.md b/guides/v2.3/graphql/reference/quote-create-cart.md new file mode 100644 index 00000000000..202465faa8b --- /dev/null +++ b/guides/v2.3/graphql/reference/quote-create-cart.md @@ -0,0 +1,73 @@ +--- +group: graphql +title: Create an empty cart +--- + +The `createEmptyCart` mutation creates an empty shopping cart for a guest or logged in customer. You can allow the system to generate a cart ID, or assign a specific ID. + +If you are creating a cart for a logged in customer, you must include the customer's authorization token in the header of the request. + +## Create an empty cart {#createEmptyCart} + +The following example creates a cart with a randomly-generated cart ID. + +### Syntax + +`mutation: {createEmptyCart}: String` + +### Example usage + +**Request** + +``` text +mutation { + createEmptyCart +} +``` + +**Response** + +The response is the quote ID, which is sometimes called the cart ID. The remaining examples in this topic will use this cart ID. + +```json +{ + "data": { + "createEmptyCart": "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C"} + } +} +``` + +## Create an empty cart with an assigned cart ID + +You can also create an empty cart with a specified `cart_id`. + +Attribute | Data Type | Description +--- | --- | --- +`cart_id` | String | A 32-character string + +### Syntax + +`mutation: {input: createEmptyCart: createEmptyCartInput}: String` + +### Example usage + +**Request** + +``` text +mutation { + createEmptyCart(input: + { cart_id: "x2345678901234567890123456789012"}) +} +``` + +**Response** + +The mutation returns the same `cart_id`. + +```json +{ + "data": { + "createEmptyCart": "x2345678901234567890123456789012" + } +} +``` \ No newline at end of file diff --git a/guides/v2.3/graphql/reference/quote-payment-method.md b/guides/v2.3/graphql/reference/quote-payment-method.md new file mode 100644 index 00000000000..05d1489588f --- /dev/null +++ b/guides/v2.3/graphql/reference/quote-payment-method.md @@ -0,0 +1,99 @@ +--- +group: graphql +title: Payment method mutations +--- + +You can use GraphQL to set the payment method on a cart. GraphQL supports the following payment methods: + +Title | Code +--- | --- +Bank Transfer Payment | `banktransfer` +Cash on Delivery | `cashondelivery` +Check / Money order | `checkmo` +No Payment Information Required | `free` +Purchase Order | `purchaseorder` + +## Set the payment method {#setPaymentMethodOnCart} + +Apply the `setPaymentMethodOnCart` mutation after setting the shipping address, shipping method and any discounts have been applied to the cart. + +### Syntax + +`mutation: {setPaymentMethodOnCart(input: SetPaymentMethodOnCartInput): SetPaymentMethodOnCartOutput}}` + +### Example usage + +The following example assigns the `banktransfer` payment method to the specified cart. + +**Request** + +```text +mutation { + setPaymentMethodOnCart(input: { + cart_id: "rMQdWEecBZr4SVWZwj2AF6y0dNCKQ8uH" + payment_method: { + code: "banktransfer" + } + }) { + cart { + selected_payment_method { + code + title + } + } + } +} +``` + +**Response** + +```json +{ + "data": { + "setPaymentMethodOnCart": { + "cart": { + "selected_payment_method": { + "code": "banktransfer", + "title": "Bank Transfer Payment" + } + } + } + } +} +``` + +### Input attributes + +The top-level `SetPaymentMethodOnCartInput` object is listed first. All child objects are listed in alphabetical order. + +#### SetPaymentMethodOnCartInput attributes {#SetPaymentMethodOnCartInput} + +The `SetPaymentMethodOnCartInput` object must contain the following attributes: + +Attribute | Data Type | Description +--- | --- | --- +`cart_id` | String! | The unique ID that identifies the customer’s cart +`payment_method` | [PaymentMethodInput!](#PaymentMethodInput) | An object containing the payment method code + +#### PaymentMethodInput attributes {#PaymentMethodInput} + +The `PaymentMethodInput` object can contain the following attributes: + +Attribute | Data Type | Description +--- | --- | --- +`code` | String! | The internal name for the payment method +`purchase_order_number` | String | The purchase order number. Optional for most payment methods + +### Output attributes + +The `SetPaymentMethodOnCartOutput` object contains the `Cart` object. + +Attribute | Data Type | Description +--- | --- | --- +`cart` | Cart! | Describes the contents of the specified shopping cart. + +#### SetPaymentMethodOnCartOutput attributes {#SetPaymentMethodOnCartOutput} + +The `SetPaymentMethodOnCartOutput` object contains the `Cart` object. + +{% include graphql/cart-object.md %} \ No newline at end of file diff --git a/guides/v2.3/graphql/reference/quote-place-order.md b/guides/v2.3/graphql/reference/quote-place-order.md new file mode 100644 index 00000000000..f519acf5d2c --- /dev/null +++ b/guides/v2.3/graphql/reference/quote-place-order.md @@ -0,0 +1,135 @@ +--- +group: graphql +title: Place an order +--- + +For guest customers, you must assign an email to the cart before you place the order. + +The email is already associated with a logged-in customer's account. Therefore, you can place the order without setting the email. + +## Set the guest's email on the cart + +The following example sets the guest email. + +### Syntax + +`mutation: {setGuestEmailOnCart(input: SetGuestEmailOnCartInput): {SetGuestEmailOnCartOutput}}` + + +### Example usage + +**Request** + +``` text +mutation { + setGuestEmailOnCart( + input: { + cart_id: "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C" + email: "jdoe@example.com" + } + ) { + cart { + email + } + } +} +``` + +**Response** + +```json +{ + "data": { + "setGuestEmailOnCart": { + "cart": { + "email": "jdoe@example.com" + } + } + } +} +``` + +### Input attributes + +The `SetGuestEmailOnCartInput` object must contain the following attributes. + +Attribute | Data Type | Description +--- | --- | --- +`cart_id` | String! | The unique ID that identifies the customer’s cart +`email` | String! | The guest user's email + +### Output attributes + +The `SetGuestEmailOnCartOutput` object contains the `Cart` object. + +Attribute | Data Type | Description +--- | --- | --- +`cart` | Cart! | Describes the contents of the specified shopping cart. + +#### SetGuestEmailOnCartOutput attributes {#SetGuestEmailOnCartOutput} + +The `SetGuestEmailOnCartOutput` object contains the `Cart` object. + +{% include graphql/cart-object.md %} + +## Place the order + +The `placeOrder` mutation converts the cart into an order and returns an order ID. You cannot manage orders with GraphQL, because orders are part of the backend. You can use REST or SOAP calls to manage orders to their completion. + +Attribute | Data Type | Description +--- | --- | --- +`cart_id` | String | A 32-character string + +### Syntax + +`mutation: {placeOrder(input: PlaceOrderInput): {PlaceOrderOutput}}` + +### Example usage + +**Request** + +``` text +mutation { + placeOrder( + input: { + cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG" + } + ) { + order { + order_id + } + } +} +``` + +**Response** + + +```json +{ + "data": { + "placeOrder": { + "order": { + "order_id": "000000006" + } + } + } +} +``` + +### Input attributes + +The `placeOrderInput` object must contain the following attribute: + + +Attribute | Data Type | Description +--- | --- | --- +`cart_id` | String! | The unique ID that identifies the customer’s cart + +### Output attributes + +The `placeOrderOutput` object contains the `order` object, which contains the following attribute: + +Attribute | Data Type | Description +--- | --- | --- +`order_id` | String! | The unique ID that identifies the order diff --git a/guides/v2.3/graphql/reference/quote-set-addresses.md b/guides/v2.3/graphql/reference/quote-set-addresses.md new file mode 100644 index 00000000000..8439e390f5c --- /dev/null +++ b/guides/v2.3/graphql/reference/quote-set-addresses.md @@ -0,0 +1,233 @@ +--- +group: graphql +title: Set billing and shipping addresses +--- + +Magento GraphQL supports billing and shipping addresses, including address books. + +## Set the billing address + +Use the `setBillingAddressOnCart` mutation to set a new billing address for a specific cart. + +If you set the `use_for_shipping` attribute to `true`, Magento assigns the same address as the shipping address. + +### Syntax + +`mutation: {setBillingAddressOnCart(input: SetBillingAddressOnCartInput) {SetBillingAddressOnCartOutput}}` + +### Example usage + +The following example creates a new billing address for a specific cart. + +**Request** + +``` text +mutation { + setBillingAddressOnCart( + input: { + cart_id: "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C" + billing_address: { + address: { + firstname: "Bob" + lastname: "Roll" + company: "Magento" + street: ["Magento Pkwy", "Main Street"] + city: "Austin" + region: "TX" + postcode: "78758" + country_code: "US" + telephone: "8675309" + save_in_address_book: true + } + use_for_shipping: false + } + } + ) { + cart { + billing_address { + firstname + lastname + company + street + city + postcode + telephone + } + } + } +} +``` + +**Response** + +```json +{ + "data": { + "setBillingAddressOnCart": { + "cart": { + "billing_address": { + "firstname": "Bob", + "lastname": "Roll", + "company": "Magento", + "street": [ + "Magento Pkwy", + "Main Street" + ], + "city": "Austin", + "postcode": "78758", + "telephone": "8675309" + } + } + } + } +} +``` + +### Input attributes + +The top-level `SetBillingAddressOnCartInput` object is listed first. All child objects are listed in alphabetical order. + +#### SetBillingAddressOnCartInput object {#SetBillingAddressOnCartInput} + +Attribute | Data Type | Description +--- | --- | --- +`billing_address` | [BillingAddressInput!](#billingAddressInput) | The billing address for a specific cart +`cart_id` | String! | The unique ID that identifies the customer's cart + +#### BillingAddressInput object {#BillingAddressInput} + +Attribute | Data Type | Description +--- | --- | --- +`address` | [CartAddressInput](#cartAddressInput) | The billing address for the cart +`customer_address_id` | Int | The unique ID that identifies the customer's address +`use_for_shipping` | Boolean | Specifies whether to use the billing address for the shipping address (`True`/`False`) + +#### CartAddressInput object {#CartAddressInput} + +{% include graphql/cart-address-input.md %} + +### Output attributes + +The `SetBillingAddressOnCartOutput` object contains the `Cart` object. + +Attribute | Data Type | Description +--- | --- | --- +`cart` | Cart! | Describes the contents of the specified shopping cart. + +#### Cart object + +{% include graphql/cart-object.md %} + +## Set shipping addresses + +Use the `setShippingAddressesOnCart` mutation to set one or more shipping addresses on a specific cart. + +### Syntax + +`mutation: {setShippingAddressesOnCart(input: SetShippingAddressesOnCartInput) {SetShippingAddressesOnCartOutput}}` + +### Example usage + +The following example sets a shipping address for a specific cart. + +**Request** + +``` text +mutation { + setShippingAddressesOnCart( + input: { + cart_id: "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C" + shipping_addresses: [ + { + address: { + firstname: "Bob" + lastname: "Roll" + company: "Magento" + street: ["Magento Pkwy", "Main Street"] + city: "Austin" + region: "TX" + postcode: "78758" + country_code: "US" + telephone: "8675309" + save_in_address_book: false + } + } + ] + } + ) { + cart { + shipping_addresses { + firstname + lastname + company + street + city + postcode + telephone + } + } + } +} +``` + +**Response** + +```json +{ + "data": { + "setShippingAddressesOnCart": { + "cart": { + "shipping_addresses": [ + { + "firstname": "Bob", + "lastname": "Roll", + "company": "Magento", + "street": [ + "Magento Pkwy", + "Main Street" + ], + "city": "Austin", + "postcode": "78758", + "telephone": "8675309" + } + ] + } + } + } +} +``` + +### Input attributes + +The top-level `SetShippingAddressesOnCartInput` object is listed first. All child objects are listed in alphabetical order. + +#### SetShippingAddressesOnCartInput object {#SetShippingAddressesOnCartInput} + +Attribute | Data Type | Description +--- | --- | --- +`cart_id` | String! | The unique ID that identifies the customer's cart +`billing_address` | [ShippingAddressInput!](#shippingAddressInput) | The billing address for a specific cart + +#### CartAddressInput object {#CartAddressInputShip} + +{% include graphql/cart-address-input.md %} + +#### ShippingAddressInput object {#ShippingAddressInput} + +Attribute | Data Type | Description +--- | --- | --- +`address` | [CartAddressInput](#CartAddressInputShip) | The shipping address for the cart +`customer_address_id` | Int | The unique ID that identifies the customer's address + + +### Output attributes + +The `SetShippingAddressOnCartOutput` object contains the `Cart` object. + +Attribute | Data Type | Description +--- | --- | --- +`cart` | Cart! | Describes the contents of the specified shopping cart. + +#### Cart object + +{% include graphql/cart-object.md %} diff --git a/guides/v2.3/graphql/reference/quote-shipping-method.md b/guides/v2.3/graphql/reference/quote-shipping-method.md new file mode 100644 index 00000000000..00cf86b2811 --- /dev/null +++ b/guides/v2.3/graphql/reference/quote-shipping-method.md @@ -0,0 +1,116 @@ +--- +group: graphql +title: Set shipping methods +--- + +## Set shipping methods + +Use the `setShippingMethodsOnCart` mutation to set one or more shipping methods on a cart. By default, Magento GraphQL supports the following shipping methods: + +Label | Carrier code | Method code +--- | --- | --- +DHL | dhl | Varies +Federal Express | fedex | Varies +Flat Rate | flatrate | flatrate +Free Shipping | freeshipping | freeshipping +Best Way | tablerate | bestway +United Parcel Service | ups | Varies +United States Postal Service | usps | Varies + +### Syntax + +`mutation: {setShippingMethodsOnCart(input: setShippingMethodsOnCartInput) {setShippingMethodsOnCartOutput}}` + +### Example usage + +The following example sets the shipping method to Best Way. + +**Request** + +``` text +mutation { + setShippingMethodsOnCart( + input: { + cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", + shipping_methods: [ + { + carrier_code: "tablerate" + method_code: "bestway" + } + ] + } + ) { + cart { + shipping_addresses { + selected_shipping_method { + carrier_code + carrier_title + method_code + method_title + amount { + value + currency + } + } + } + } + } +} +``` + +**Response** + +```json +{ + "data": { + "setShippingMethodsOnCart": { + "cart": { + "shipping_addresses": [ + { + "selected_shipping_method": { + "carrier_code": "tablerate", + "carrier_title": "Best Way", + "method_code": "bestway", + "method_title": "Table Rate", + "amount": { + "value": 0, + "currency": "USD" + } + } + } + ] + } + } + } +} +``` + +### Input attributes + +The top-level `setShippingMethodsOnCartInput` object is listed first. All child objects are listed in alphabetical order. + +#### setShippingMethodsOnCartInput object {#setShippingMethodsOnCartInput} + +Attribute | Data Type | Description +--- | --- | --- +`cart_id` | String! | The unique ID that identifies the customer's cart +`shipping_methods` | [ShippingMethodInput!](#ShippingMethodInput) | The billing address for a specific cart + +#### ShippingMethodInput object {#ShippingMethodInput} + +Attribute | Data Type | Description +--- | --- | --- +`carrier_code` | String! | A string that identifies a commercial carrier or an offline shipping method +`method_code` | String! | A string that indicates which service a commercial carrier will use to ship items. For offline shipping methods, this value is similar to the label displayed on the checkout page + +### Output attributes + +The `ShippingMethodInput` object contains the `Cart` object. + +Attribute | Data Type | Description +--- | --- | --- +`cart` | Cart! | Describes the contents of the specified shopping cart. + +#### Cart object + +{% include graphql/cart-object.md %} diff --git a/guides/v2.3/graphql/reference/quote-update-remove-products.md b/guides/v2.3/graphql/reference/quote-update-remove-products.md new file mode 100644 index 00000000000..4738b327823 --- /dev/null +++ b/guides/v2.3/graphql/reference/quote-update-remove-products.md @@ -0,0 +1,214 @@ +--- +group: graphql +title: Update and remove products +--- + +Use the `updateCartItems` and `removeItemFromCart` mutations to manage the quantity of items in the cart. + +## Update cart items + +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. + +{:.bs-callout .bs-callout-info} +Setting the quantity to 0 removes an item from the cart. + +### Syntax + +`mutation; {updateCartItems(input: UpdateCartItemsInput): UpdateCartItemsOutput}` + +### Example usage + +The following example changes the quantity of cart item 13 to 3. + +**Request** + +```text +mutation { + updateCartItems( + input: { + cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", + cart_items: [ + { + cart_item_id: 13 + quantity: 3 + } + ] + } + ){ + cart { + items { + id + product { + name + } + quantity + } + prices { + grand_total{ + value + currency + } + } + } +} +``` + +**Response** + +```json +{ + "data": { + "updateCartItems": { + "cart": { + "items": [ + { + "id": "13", + "product": { + "name": "Strive Shoulder Pack" + }, + "quantity": 3 + }, + { + "id": "14", + "product": { + "name": "Affirm Water Bottle " + }, + "quantity": 1 + } + ], + "prices": { + "grand_total": { + "value": 103, + "currency": "USD" + } + } + } + } + } +} +``` + +### Input attributes + +The `UpdateCartItemsInput` object is listed first. All child objects are listed in alphabetical order. + +#### UpdateCartItemsInput object {#UpdateCartItemsInput} + +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! | Contains the cart item IDs and quantity of each item + +#### CartItemUpdateInput object + +The `CartItemUpdateInput` object must 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 +`quantity` | Float! | The new quantity of the item. A value of 0 removes the item from the cart. + +### Output attributes + +The `UpdateCartItemsOutut` object contains the `Cart` object. + +Attribute | Data Type | Description +--- | --- | --- +`cart` | Cart! | Describes the contents of the specified shopping cart. + +#### Cart object + +{% include graphql/cart-object.md %} + +## Remove items from a cart + +The `removeItemFromCart` mutation deletes the entire quantity of a specified item from the cart. If you remove all items from the cart, the cart continues to exist. + +### Syntax + +`mutation; {removeItemFromCart(input: RemoveItemFromCartInput): RemoveItemFromCartOutput}` + +### Example usage + +The following example removes cart item 14 from the cart. + +**Request** + +```text +mutation { + removeItemFromCart( + input: { + cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", + cart_item_id: 14 + } + ){ + cart { + items { + id + product { + name + } + quantity + } + prices { + grand_total{ + value + currency + } + } + } +} +``` + +**Response** + +```json +{ + "data": { + "removeItemFromCart": { + "cart": { + "items": [ + { + "id": "13", + "product": { + "name": "Strive Shoulder Pack" + }, + "quantity": 3 + } + ], + "prices": { + "grand_total": { + "value": 96, + "currency": "USD" + } + } + } + } + } +} +``` + +### Input attributes + +#### RemoveItemFromCartInput object {#RemoveItemFromCartInput} + +The `RemoveItemFromCartInput` object must contain the following attributes: + +Attribute | Data Type | Description +--- | --- | --- +`cart_id` | String! | The unique ID that identifies the customer's cart +`cart_item_id` | Int! | The unique ID assigned when a customer places an item in the cart + +### Output attributes + +The `UpdateCartItemsOutut` object contains the `Cart` object. + +Attribute | Data Type | Description +--- | --- | --- +`cart` | Cart! | Describes the contents of the specified shopping cart. + +#### Cart object + +{% include graphql/cart-object.md %} \ No newline at end of file diff --git a/guides/v2.3/graphql/reference/quote.md b/guides/v2.3/graphql/reference/quote.md index 75406078363..8927bd6b82c 100644 --- a/guides/v2.3/graphql/reference/quote.md +++ b/guides/v2.3/graphql/reference/quote.md @@ -9,210 +9,120 @@ A Quote represents the contents of a customer's shopping cart. It is responsible * Determining estimated shipping costs * Calculating subtotals, computing additional costs, applying coupons, and determining the payment method -{:.bs-callout .bs-callout-tip} -Except for `createEmptyCart`, the mutations defined in this topic are available in the 2.3-develop branch of the [graphql-ce repository](https://github.com/magento/graphql-ce). - ## Query -Use the `Cart` query to retrieve information about a particular cart. +Use the `cart` query to retrieve information about a particular cart. ### Syntax `{cart(cart_id: String!) {Cart}}` -### Cart attributes -The `Cart` object can contain the following attributes: - -Attribute | Data Type | Description ---- | --- | --- -`applied_coupon` | AppliedCoupon | The `AppliedCoupon` object contains the code text attribute, which provides the coupon code -`available_payment_methods` | AvailablePaymentMethod | Available payment methods -`billing_address` | [CartAddress](#cartAddressAttributes) | Contains the billing address specified in the customer's cart -`email` | String | The customer's email address -`items` | [CartItemInterface](#cartItemsInterface) | Contains the items in the customer's cart -`selected_payment_method` | SelectedPaymentMethod | Selected payment method -`shipping_addresses` | [CartAddress](#cartAddressAttributes) | Contains one or more shipping addresses - -### Available Payment Method attributes - -the `AvailablePaymentMethod` object must contain the following attributes: - -Attribute | Data Type | Description ---- | --- | --- -`code` | String | The payment method code -`title` | String | The payment method title - -### Cart address attributes {#cartAddressAttributes} -The `CartAddress` object can contain the following attributes: - -Attribute | Data Type | Description ---- | --- | --- -`address_type` | AddressTypeEnum | Specifies if the type of address is SHIPPING or BILLING -`cart_items` | CartItemQuantity | Contains the cart item IDs and quantity of each item -`city` | String | The city specified for the shipping or billing address -`company` | String | The company specified for the shipping or billing address -`country` | [CartAddressCountry] | The country code and label for the shipping or billing address -`customer_notes` | String | Comments made to the customer that accompanies the order -`firstname` | String | The customer's first name -`items_weight` | Float | The total weight of the items in the cart -`lastname` | String | The customer's last name -`postcode` | String | The postal code for the shipping or billing address -`region` | CartAddressRegion | An object containing the region name, region code, and region ID -`street` | [String] | The street for the shipping or billing address -`telephone` | String | The telephone number for the shipping or billing address - -### Cart item interface attributes {#cartItemsInterface} -The `CartItemInterface` object can contain the following attributes: - -Attribute | Data Type | Description ---- | --- | --- -`id` | String | ID of the item -`product` | [ProductInterface]({{ page.baseurl }}/graphql/reference/product-interface-implementations.html) | Contains attributes that are common to all types of products -`qty` | Float | The number of items in the cart - -## Selected Payment Method attributes - -the `SelectedPaymentMethod` object can contain the following attributes: - -Attribute | Data Type | Description ---- | --- | --- -`code` | String | The payment method code -`purchase_order_number` | String | The purchase order number -`title` | String | The payment method title - ### Example usage -The following returns information about a cart given a `cart_id`. Note that the `cart_id` specified is for demonstration purposes only. You will need to [generate](#createEmptyCart) your own `cart_id` for this example to work. +The following query shows the status of a cart that is ready to be converted into an order. **Request** -``` text -{ - cart(cart_id: "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C") { +```text +query { + cart(cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG") + { + email billing_address { + city + country { + code + label + } + firstname lastname - firstname postcode - } - items { - id - qty + region { + code + label + } + street + telephone } shipping_addresses { - company - postcode - lastname firstname - } - } -} -``` -**Response** - -```json -{ - "data": { - "cart": { - "items": [ - { - "id": "22", - "qty": 1 + lastname + street + city + region { + code + label + } + country { + code + label + } + telephone + available_shipping_methods { + amount { + currency + value } - ], - "billing_address": - { - "lastname": "Roll", - "firstname": "Bob", - "postcode": "78759" - }, - "shipping_addresses": [ - { - "company": "Magento", - "postcode": "78759", - "lastname": "Roll", - "firstname": "Bob" + available + base_amount { + value + currency } - ] - } - } -} -``` - -## Mutations - -### Create an empty cart {#createEmptyCart} - -The `createEmptyCart` mutation creates an empty shopping cart for a guest or logged in customer. If you are creating a cart for a logged in customer, you must include the customer's authorization token in the header of the request. - -#### Syntax - -`mutation: {createEmptyCart: String}` - -**Request** - -``` text -mutation { - createEmptyCart -} -``` - -**Response** - -The response is the quote ID, which is sometimes called the cart ID. The remaining examples in this topic will use this cart ID. - -```json -{ - "data": { - "createEmptyCart": "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C"} - } -} -``` - -### Adding simple products to a cart - -Adds simple items to a specific cart. - -### Add simple products to cart attributes -The `addSimpleProductsToCart` object can contain the following attributes: - -Attribute | Data Type | Description ---- | --- | --- -`cartItems` | SimpleProductCartItemInput | The list of items to add to the cart -`cart_id` | String | The unique ID that identifies the customer's cart - -#### Syntax - -`mutation: {addSimpleProductsToCart(input: AddSimpleProductsToCartInput) {AddSimpleProductsToCartOutput}}` - -#### Example usage - -The following example adds two Joust Duffle Bags to the cart. - -**Request** - -``` text -mutation { - addSimpleProductsToCart( - input: { - cart_id: "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C", - cartItems: [ - { - data: { - qty: 2 - sku: "24-MB01" - } + carrier_code + carrier_title + error_message + method_code + method_title + price_excl_tax { + value + currency + } + price_incl_tax { + value + currency + } + } + selected_shipping_method { + amount { + value + currency + } + base_amount { + value + currency } - ] + carrier_code + carrier_title + method_code + method_title + } + } - ) { - cart { - items { + items { + id product { name + sku } - qty + quantity } + available_payment_methods { + code + title } - } + selected_payment_method { + code + title + } + applied_coupon { + code + } + prices { + grand_total{ + value + currency + } + } + } } ``` @@ -221,59 +131,268 @@ mutation { ```json { "data": { - "addSimpleProductsToCart": { - "cart": { - "items": [ - { - "product": { - "name": "Joust Duffle Bag" + "cart": { + "email": "mshaw@example.com", + "billing_address": { + "city": "Calder", + "country": { + "code": "US", + "label": "US" + }, + "firstname": "Bob", + "lastname": "Roll", + "postcode": "49628", + "region": { + "code": "MI", + "label": "Michigan" + }, + "street": [ + "Magento Pkwy", + "Main Street" + ], + "telephone": "8675309" + }, + "shipping_addresses": [ + { + "firstname": "Bob", + "lastname": "Roll", + "street": [ + "Magento Pkwy", + "Main Street" + ], + "city": "Austin", + "region": { + "code": "TX", + "label": "Texas" + }, + "country": { + "code": "US", + "label": "US" + }, + "telephone": "8675309", + "available_shipping_methods": [ + { + "amount": { + "currency": "USD", + "value": 20 + }, + "available": true, + "base_amount": { + "value": 20, + "currency": "USD" + }, + "carrier_code": "flatrate", + "carrier_title": "Flat Rate", + "error_message": "", + "method_code": "flatrate", + "method_title": "Fixed", + "price_excl_tax": { + "value": 20, + "currency": "USD" + }, + "price_incl_tax": { + "value": 20, + "currency": "USD" + } + }, + { + "amount": { + "currency": "USD", + "value": 5 + }, + "available": true, + "base_amount": { + "value": 5, + "currency": "USD" + }, + "carrier_code": "tablerate", + "carrier_title": "Best Way", + "error_message": "", + "method_code": "bestway", + "method_title": "Table Rate", + "price_excl_tax": { + "value": 5, + "currency": "USD" + }, + "price_incl_tax": { + "value": 5, + "currency": "USD" + } }, - "qty": 2 + { + "amount": { + "currency": "USD", + "value": 11.41 + }, + "available": true, + "base_amount": { + "value": 11.41, + "currency": "USD" + }, + "carrier_code": "ups", + "carrier_title": "United Parcel Service", + "error_message": "", + "method_code": "03", + "method_title": "UPS Ground", + "price_excl_tax": { + "value": 11.41, + "currency": "USD" + }, + "price_incl_tax": { + "value": 11.41, + "currency": "USD" + } + }, + { + "amount": { + "currency": "USD", + "value": 26.81 + }, + "available": true, + "base_amount": { + "value": 26.81, + "currency": "USD" + }, + "carrier_code": "ups", + "carrier_title": "United Parcel Service", + "error_message": "", + "method_code": "12", + "method_title": "UPS Three-Day Select", + "price_excl_tax": { + "value": 26.81, + "currency": "USD" + }, + "price_incl_tax": { + "value": 26.81, + "currency": "USD" + } + }, + { + "amount": { + "currency": "USD", + "value": 34.27 + }, + "available": true, + "base_amount": { + "value": 34.27, + "currency": "USD" + }, + "carrier_code": "ups", + "carrier_title": "United Parcel Service", + "error_message": "", + "method_code": "02", + "method_title": "UPS Second Day Air", + "price_excl_tax": { + "value": 34.27, + "currency": "USD" + }, + "price_incl_tax": { + "value": 34.27, + "currency": "USD" + } + }, + { + "amount": { + "currency": "USD", + "value": 76.12 + }, + "available": true, + "base_amount": { + "value": 76.12, + "currency": "USD" + }, + "carrier_code": "ups", + "carrier_title": "United Parcel Service", + "error_message": "", + "method_code": "01", + "method_title": "UPS Next Day Air", + "price_excl_tax": { + "value": 76.12, + "currency": "USD" + }, + "price_incl_tax": { + "value": 76.12, + "currency": "USD" + } + }, + { + "amount": { + "currency": "USD", + "value": 108.52 + }, + "available": true, + "base_amount": { + "value": 108.52, + "currency": "USD" + }, + "carrier_code": "ups", + "carrier_title": "United Parcel Service", + "error_message": "", + "method_code": "14", + "method_title": "UPS Next Day Air Early A.M.", + "price_excl_tax": { + "value": 108.52, + "currency": "USD" + }, + "price_incl_tax": { + "value": 108.52, + "currency": "USD" + } + } + ], + "selected_shipping_method": { + "amount": { + "value": 5, + "currency": "USD" + }, + "base_amount": { + "value": 5, + "currency": "USD" + }, + "carrier_code": "tablerate", + "carrier_title": "Best Way", + "method_code": "bestway", + "method_title": "Table Rate" } - ] - } - } - } -} -``` - -### Adding simple product with customizable options to a cart - -If a product has a customizable option, the option's value can be specified in the add to cart request. - -**Request** - -``` text -mutation { - addSimpleProductsToCart (input: { - cart_id: "nu31JXR9DaqbdVqFDGnqjrMJmUnT3mzB" - cartItems: { - data: { - sku:"simple" - qty:1 - }, - customizable_options: [ + } + ], + "items": [ { - id: 121 - value: "field value" + "id": "13", + "product": { + "name": "Strive Shoulder Pack", + "sku": "24-MB04" + }, + "quantity": 4 } - ] - } - }) { - cart { - items { - product { - name + ], + "available_payment_methods": [ + { + "code": "cashondelivery", + "title": "Cash On Delivery" + }, + { + "code": "banktransfer", + "title": "Bank Transfer Payment" + }, + { + "code": "purchaseorder", + "title": "Purchase Order" + }, + { + "code": "checkmo", + "title": "Check / Money order" } - qty - - ... on SimpleCartItem { - customizable_options { - label - values { - value - } - } + ], + "selected_payment_method": { + "code": "banktransfer", + "title": "Bank Transfer Payment" + }, + "applied_coupon": null, + "prices": { + "grand_total": { + "value": 133, + "currency": "USD" } } } @@ -281,329 +400,186 @@ mutation { } ``` -**Response** +### Input attributes -```text -{ - "data": { - "addSimpleProductsToCart": { - "cart": { - "items": [ - { - "product": { - "name": "simple" - }, - "qty": 2, - "customizable_options": [ - { - "label": "Field Option", - "values": [ - { - "value": "field value" - } - ] - } - ] - } - ] - } - } - } -} -``` +Attribute | Data Type | Description +--- | --- | --- +`cart_id` | String | A 32-character string that is created when you [create a cart]({{page.baseurl}}/graphql/reference/quote-create-cart.html) +### Output attributes -### Updating billing and shipping information -{:.no_toc} +The top-level `Cart` object is listed first. All child objects are listed in alphabetical order. -You can set the billing and shipping addresses on a cart. +#### Cart object + +The `Cart` object can contain the following attributes: -### Set the billing address on cart attributes -The `setBillingAddressOnCart` object can contain the following attributes: +{% include graphql/cart-object.md %} + + +#### AppliedCoupon object {#AppliedCoupon} + +The `AppliedCoupon` object must contain the following attributes: Attribute | Data Type | Description --- | --- | --- -`billing_address` | [BillingAddressInput](#billingAddressInput) | The billing address for a specific cart -`cart_id` | String | The unique ID that identifies the customer's cart +`code` | String! | The coupon code applied to the order + +#### AvailablePaymentMethod object {#AvailablePaymentMethod} + +The `AvailablePaymentMethod` object must contain the following attributes: + +Attribute | Data Type | Description +--- | --- | --- +`code` | String! | The payment method code +`title` | String! | The payment method title + +#### AvailableShippingMethod object {#AvailableShippingMethod} -### Set the billing address input attributes {#billingAddressInput} -The `BillingAddressInput` object can contain the following attributes: +The `AvailableShippingMethod` object can contain the following attributes: Attribute | Data Type | Description --- | --- | --- -`address` | [CartAddressInput](#cartAddressInput) | The billing address for the cart -`customer_address_id` | Int | The unique ID that identifies the customer's address -`use_for_shipping` | Boolean | Specifies whether to use the billing address for the shipping address (`True`/`False`) +`amount` | Money! | The cost of shipping using this shipping method +`available` | Boolean! | Indicates whether this shipping method can be applied to the cart +`base_amount` | Money | The base shipping cost, not including taxes or other cost adjustment. Could be null if method is not available +`carrier_code` | String! | A string that identifies a commercial carrier or an offline shipping method +`carrier_title` | String! | The label for the carrier code +`error_message` | String | Describes an error condition +`method_code` | String | A shipping method code associated with a carrier. Could be null if method is not available +`method_title` | String | The label for the method code. Could be null if method is not available +`price_excl_tax` | Money! | The cost of shipping using this shipping method, excluding tax +`price_incl_tax` | Money! | The cost of shipping using this shipping method, excluding tax -### Cart address input attributes {#cartAddressInput} -The `CartAddressInput` object can contain the following attributes: +#### BillingCartAddress object {#BillingCartAddress} + +The `BillingCartAddress` object can contain the following attributes: Attribute | Data Type | Description --- | --- | --- `city` | String | The city specified for the billing address `company` | String | The company specified for the billing address -`country_code` | String | The country code and label for the billing address +`country` | [CartAddressCountry](#CartAddressCountry) | The country code and label for the billing address +`customer_notes` | String | Comments made to the customer that accompanies the order `firstname` | String | The customer's first name `lastname` | String | The customer's last name `postcode` | String | The postal code for the billing address -`region` | String | The region code and label for the billing address -`save_in_address_book` | Boolean | Specifies whether to save the address (`True`/`False`) +`region` | [CartAddressRegion](#CartAddressRegion) | An object containing the region label and code `street` | [String] | The street for the billing address `telephone` | String | The telephone number for the billing address -### Set the billing address on a cart - -Use the `setBillingAddressOnCart` mutation to set a new billing address for a specific cart. - -#### Syntax - -`mutation: {setBillingAddressOnCart(input: SetBillingAddressOnCartInput) {SetBillingAddressOnCartOutput}}` - -#### Example usage - -The following example creates a new billing address for a specific cart. - -**Request** - -``` text -mutation { - setBillingAddressOnCart( - input: { - cart_id: "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C" - billing_address: { - address: { - firstname: "Bob" - lastname: "Roll" - company: "Magento" - street: ["Magento Pkwy", "Main Street"] - city: "Austin" - region: "TX" - postcode: "78758" - country_code: "US" - telephone: "8675309" - save_in_address_book: false - } - } - } - ) { - cart { - billing_address { - firstname - lastname - company - street - city - postcode - telephone - } - } - } -} -``` - -**Response** - -```json -{ - "data": { - "setBillingAddressOnCart": { - "cart": { - "billing_address": { - "firstname": "Bob", - "lastname": "Roll", - "company": "Magento", - "street": [ - "Magento Pkwy", - "Main Street" - ], - "city": "Austin", - "postcode": "78758", - "telephone": "8675309" - } - } - } - } -} -``` - -### Set the shipping address on a cart - -Use the `setShippingAddressesOnCart` mutation to set a new shipping address for a specific cart. +#### CartAddressCountry object {#CartAddressCountry} -#### Syntax +The `CartAddressCountry` object can contain the following attributes: -`mutation: {setShippingAddressesOnCart(input: SetShippingAddressesOnCartInput) {SetShippingAddressesOnCartOutput}}` +Attribute | Data Type | Description +--- | --- | --- +`code` | String | The country code +`label` | String | The display label for the country -#### Example usage +#### CartAddressRegion object {#CartAddressRegion} -The following example creates a new shipping address for a specific cart. +The `CartAddressRegion` object can contain the following attributes: -**Request** - -``` text -mutation { - setShippingAddressesOnCart( - input: { - cart_id: "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C" - shipping_addresses: [ - { - address: { - firstname: "Bob" - lastname: "Roll" - company: "Magento" - street: ["Magento Pkwy", "Main Street"] - city: "Austin" - region: "TX" - postcode: "78758" - country_code: "US" - telephone: "8675309" - save_in_address_book: false - } - } - ] - } - ) { - cart { - shipping_addresses { - firstname - lastname - company - street - city - postcode - telephone - } - } - } -} -``` +Attribute | Data Type | Description +--- | --- | --- +`code` | String | The state or province code +`label` | String | The display label for the region -**Response** +#### CartItemInterface object {#CartItemInterface} -```json -{ - "data": { - "setShippingAddressesOnCart": { - "cart": { - "shipping_addresses": [ - { - "firstname": "Bob", - "lastname": "Roll", - "company": "Magento", - "street": [ - "Magento Pkwy", - "Main Street" - ], - "city": "Austin", - "postcode": "78758", - "telephone": "8675309" - } - ] - } - } - } -} -``` +The `CartItemInterface` object can contain the following attributes: -### Add and remove coupons from a cart -{:.no_toc} +Attribute | Data Type | Description +--- | --- | --- +`id` | String | ID of the item +`product` | [ProductInterface]({{ page.baseurl }}/graphql/reference/product-interface-implementations.html) | Contains attributes that are common to all types of products +`quantity` | Float | The number of items in the cart -You can use mutations to add or remove coupons from a specified cart. +#### CartItemQuantity object {#CartItemQuantity} -### Coupon attributes -{:.no_toc} -The add and remove coupon from cart objects can contain the following attributes: +The `CartItemQuantity` object must contain the following attributes: Attribute | Data Type | Description --- | --- | --- -`cart_id` | String | The unique ID that identifies the customer's cart -`coupon_code` | String | The coupon code +`cart_item_id` | Int! | The unique ID assigned when a customer places an item in the cart +`quantity` | Float! | The quantity of this item selected -### Apply coupon to cart +#### CartPrices object {#CartPrices} -Adds a coupon code to a cart. +The `CartPrices` object can contain the following attributes: -#### Syntax - -`mutation: {applyCouponToCart(input: ApplyCouponToCartInput) {ApplyCouponToCartOutput}}` +Attribute | Data Type | Description +--- | --- | --- +`applied_taxes` | [[CartTaxItem]](#CartTaxItem) | An array containing the names and amounts of taxes applied to the item +`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 +`subtotal_with_discount_excluding_tax` | Money | Subtotal with any discounts applied, but not taxes -#### Example usage +#### CartTaxItem object {#CartTaxItem} -The following call adds a coupon code called `test2019` to a cart. +The `CartTaxItem` object must contain the following attributes: -**Request** +Attribute | Data Type | Description +--- | --- | --- +`amount` | Money! | The amount of tax applied to the item +`label` | String! | The description of the tax -``` text -mutation { - applyCouponToCart( - input: { - cart_id: "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C" - coupon_code: "test2019" - } - ) { - cart { - applied_coupon { - code - } - } - } -} -``` +#### SelectedPaymentMethod object {#SelectedPaymentMethod} -**Response** +The `SelectedPaymentMethod` object can contain the following attributes: -```json -{ - "data": { - "applyCouponToCart": { - "cart": { - "applied_coupon": { - "code": "test2019" - } - } - } - } -} -``` +Attribute | Data Type | Description +--- | --- | --- +`code` | String! | The payment method code +`purchase_order_number` | String | The purchase order number +`title` | String! | The payment method title -### Remove coupon from cart +#### SelectedShippingMethod object {#SelectedShippingMethod} -Removes a coupon from the specified cart. +The `SelectedShippingMethod` object can contain the following attributes: -#### Syntax +Attribute | Data Type | Description +--- | --- | --- +`amount` | Money | The cost of shipping using this shipping method +`base_amount` | Money | The base shipping cost, not including taxes or other cost adjustment +`carrier_code` | String | A string that identifies a commercial carrier or an offline shipping method +`carrier_title` | String | The label for the carrier code +`method_code` | String | A shipping method code associated with a carrier +`method_title` | String | The label for the method code -`mutation: {removeCouponFromCart(input: RemoveCouponFromCartInput){ RemoveCouponFromCartOutput}}` +#### ShippingCart object {#ShippingCart} -#### Example usage +The `ShippingCart` object can contain the following attributes: -The following example removes a coupon from the cart. +Attribute | Data Type | Description +--- | --- | --- +`available_shipping_methods` | [[AvailableShippingMethod]](#AvailableShippingMethod) | An array that lists the shipping methods that can be applied to the cart +`cart_items` | [[CartItemQuantity]](#CartItemQuantity) | An array that lists the items in the cart +`city` | String | The city specified for the shipping address +`company` | String | The company specified for the shipping address +`country` | [CartAddressCountry](#CartAddressCountry) | The country code and label for the shipping address +`customer_notes` | String | Comments made to the customer that will accompany the order +`firstname` | String | The recipient's first name +`items_weight` | Float | The weight of all items in the cart +`lastname` | String | The recipient's last name +`postcode` | String | The postal code for the shipping address +`region` | [CartAddressRegion](#CartAddressRegion) | An object containing the region label and code +`selected_shipping_method` | [SelectedShippingMethod](#SelectedShippingMethod) | An object that describes the selected shipping method +`street` | [String] | The street for the shipping address +`telephone` | String | The telephone number for the shipping address -**Request** -``` text -mutation { - removeCouponFromCart(input: { cart_id: "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C" }) { - cart { - applied_coupon { - code - } - } - } -} -``` +## Mutations -**Response** +The following topics describe the mutations defined in the `QuoteGraphQl` module: -```json -{ - "data": { - "removeCouponFromCart": { - "cart": { - "applied_coupon": { - "code": "test2019" - } - } - } - } -} -``` +* [Create a cart]({{page.baseurl}}/graphql/reference/quote-create-cart.html) +* [Add products to a cart]({{page.baseurl}}/graphql/reference/quote-add-products.html) +* [Update and remove products]({{page.baseurl}}/graphql/reference/quote-update-remove-products.html) +* [Manage coupons]({{page.baseurl}}/graphql/reference/quote-apply-discount.html) +* [Set billing and shipping addresses]({{page.baseurl}}/graphql/reference/quote-set-addresses.html) +* [Set shipping methods]({{page.baseurl}}/graphql/reference/quote-shipping-method.html) +* [Set the payment method]({{page.baseurl}}/graphql/reference/quote-payment-method.html) +* [Place an order]({{page.baseurl}}/graphql/reference/quote-place-order.html) From d2929a7f387ae17f30f0dfe1f5846fce8be07443 Mon Sep 17 00:00:00 2001 From: Kevin Harper Date: Mon, 13 May 2019 08:23:33 -0500 Subject: [PATCH 2/6] fix broken links --- _includes/graphql/cart-object.md | 6 +++--- guides/v2.3/graphql/reference/configurable-product.md | 2 +- guides/v2.3/graphql/reference/quote-set-addresses.md | 6 +++--- guides/v2.3/graphql/reference/quote.md | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/_includes/graphql/cart-object.md b/_includes/graphql/cart-object.md index d8152dc3157..73ad0a7fa30 100644 --- a/_includes/graphql/cart-object.md +++ b/_includes/graphql/cart-object.md @@ -10,9 +10,9 @@ Attribute | Data Type | Description `shipping_addresses` | [ShippingCartAddress][ShippingCartAddress] | Contains one or more shipping addresses [AppliedCoupon]: {{page.baseurl}}/graphql/reference/quote.html#AppliedCoupon -[AvailablePaymentMethod]: {{page.baseurl}}/reference/quote.html#AvailablePaymentMethod -[BillingCartAddress]: {{page.baseurl}}/reference/quote.html#BillingCartAddress +[AvailablePaymentMethod]: {{page.baseurl}}/graphql/reference/quote.html#AvailablePaymentMethod +[BillingCartAddress]: {{page.baseurl}}/graphql/reference/quote.html#BillingCartAddress [CartItemInterface]: {{page.baseurl}}/graphql/reference/quote.html#CartItemInterface [CartPrices]: {{page.baseurl}}/graphql/reference/quote.html#CartPrices [SelectedPaymentMethod]: {{page.baseurl}}/graphql/reference/quote.html#SelectedPaymentMethod -[ShippingCartAddress]: {{page.baseurl}}/graphql/reference/quote.html#AppliedShippingCartAddressCoupon +[ShippingCartAddress]: {{page.baseurl}}/graphql/reference/quote.html#ShippingCartAddress diff --git a/guides/v2.3/graphql/reference/configurable-product.md b/guides/v2.3/graphql/reference/configurable-product.md index 62a5dffab53..ad1f2f9961b 100644 --- a/guides/v2.3/graphql/reference/configurable-product.md +++ b/guides/v2.3/graphql/reference/configurable-product.md @@ -720,7 +720,7 @@ Attribute | Type | Description ### Example usage -The following example adds two black Teton Pullover Hoodies size extra-small to the specified shopping cart. The `cart_id` used in this example was [generated]({{ page.baseurl }}/graphql/reference/quote.html#createEmptyCart) by creating an empty cart. +The following example adds two black Teton Pullover Hoodies size extra-small to the specified shopping cart. The `cart_id` used in this example was [generated]({{ page.baseurl }}/graphql/reference/quote-create-cart.html) by creating an empty cart. **Request** diff --git a/guides/v2.3/graphql/reference/quote-set-addresses.md b/guides/v2.3/graphql/reference/quote-set-addresses.md index 8439e390f5c..199887d0fd4 100644 --- a/guides/v2.3/graphql/reference/quote-set-addresses.md +++ b/guides/v2.3/graphql/reference/quote-set-addresses.md @@ -91,14 +91,14 @@ The top-level `SetBillingAddressOnCartInput` object is listed first. All child o Attribute | Data Type | Description --- | --- | --- -`billing_address` | [BillingAddressInput!](#billingAddressInput) | The billing address for a specific cart +`billing_address` | [BillingAddressInput!](#BillingAddressInput) | The billing address for a specific cart `cart_id` | String! | The unique ID that identifies the customer's cart #### BillingAddressInput object {#BillingAddressInput} Attribute | Data Type | Description --- | --- | --- -`address` | [CartAddressInput](#cartAddressInput) | The billing address for the cart +`address` | [CartAddressInput](#CartAddressInput) | The billing address for the cart `customer_address_id` | Int | The unique ID that identifies the customer's address `use_for_shipping` | Boolean | Specifies whether to use the billing address for the shipping address (`True`/`False`) @@ -206,7 +206,7 @@ The top-level `SetShippingAddressesOnCartInput` object is listed first. All chil Attribute | Data Type | Description --- | --- | --- `cart_id` | String! | The unique ID that identifies the customer's cart -`billing_address` | [ShippingAddressInput!](#shippingAddressInput) | The billing address for a specific cart +`billing_address` | [ShippingAddressInput!](#ShippingAddressInput) | The billing address for a specific cart #### CartAddressInput object {#CartAddressInputShip} diff --git a/guides/v2.3/graphql/reference/quote.md b/guides/v2.3/graphql/reference/quote.md index 8927bd6b82c..9232e17912a 100644 --- a/guides/v2.3/graphql/reference/quote.md +++ b/guides/v2.3/graphql/reference/quote.md @@ -549,9 +549,9 @@ Attribute | Data Type | Description `method_code` | String | A shipping method code associated with a carrier `method_title` | String | The label for the method code -#### ShippingCart object {#ShippingCart} +#### ShippingCartAddress object {#ShippingCartAddress} -The `ShippingCart` object can contain the following attributes: +The `ShippingCartAddress` object can contain the following attributes: Attribute | Data Type | Description --- | --- | --- From 11b4b8d2798cdeb2b00f905fde66fb1b0bbb64cc Mon Sep 17 00:00:00 2001 From: Kevin Harper Date: Mon, 13 May 2019 15:36:07 -0500 Subject: [PATCH 3/6] one mutation per topic --- _data/toc/graphql.yml | 48 ++- .../graphql/reference/quote-add-products.md | 320 ------------------ .../reference/quote-add-simple-products.md | 194 +++++++++++ .../reference/quote-add-virtual-products.md | 126 +++++++ .../graphql/reference/quote-apply-coupon.md | 113 +++++++ .../graphql/reference/quote-apply-discount.md | 216 ------------ .../graphql/reference/quote-create-cart.md | 15 +- .../graphql/reference/quote-payment-method.md | 24 +- .../graphql/reference/quote-place-order.md | 93 +---- .../graphql/reference/quote-remove-coupon.md | 101 ++++++ .../graphql/reference/quote-remove-item.md | 93 +++++ .../graphql/reference/quote-set-addresses.md | 233 ------------- .../reference/quote-set-billing-address.md | 113 +++++++ .../reference/quote-set-guest-email.md | 68 ++++ .../reference/quote-set-shipping-address.md | 117 +++++++ .../reference/quote-shipping-method.md | 20 +- .../reference/quote-update-cart-items.md | 119 +++++++ .../reference/quote-update-remove-products.md | 214 ------------ guides/v2.3/graphql/reference/quote.md | 11 +- 19 files changed, 1117 insertions(+), 1121 deletions(-) delete mode 100644 guides/v2.3/graphql/reference/quote-add-products.md create mode 100644 guides/v2.3/graphql/reference/quote-add-simple-products.md create mode 100644 guides/v2.3/graphql/reference/quote-add-virtual-products.md create mode 100644 guides/v2.3/graphql/reference/quote-apply-coupon.md delete mode 100644 guides/v2.3/graphql/reference/quote-apply-discount.md create mode 100644 guides/v2.3/graphql/reference/quote-remove-coupon.md create mode 100644 guides/v2.3/graphql/reference/quote-remove-item.md delete mode 100644 guides/v2.3/graphql/reference/quote-set-addresses.md create mode 100644 guides/v2.3/graphql/reference/quote-set-billing-address.md create mode 100644 guides/v2.3/graphql/reference/quote-set-guest-email.md create mode 100644 guides/v2.3/graphql/reference/quote-set-shipping-address.md create mode 100644 guides/v2.3/graphql/reference/quote-update-cart-items.md delete mode 100644 guides/v2.3/graphql/reference/quote-update-remove-products.md diff --git a/_data/toc/graphql.yml b/_data/toc/graphql.yml index 1bb2a8f3722..55a5f970293 100644 --- a/_data/toc/graphql.yml +++ b/_data/toc/graphql.yml @@ -86,34 +86,48 @@ pages: - label: GroupedProduct endpoint url: /graphql/reference/grouped-product.html - - label: Quote endpoint + - label: Quote endpoint (cart query) + url: /graphql/reference/quote.html children: - - label: Query a cart - url: /graphql/reference/quote.html - - label: Create a cart + - label: addSimpleProductsToCart mutation + url: /graphql/reference/quote-add-simple-products.html + + - label: addVirtualProductsToCart mutation + url: /graphql/reference/quote-add-virtual-products.html + + - label: applyCouponToCart mutation + url: /graphql/reference/quote-apply-coupon.html + + - label: createEmptyCart mutation url: /graphql/reference/quote-create-cart.html - - label: Add products to a cart - url: /graphql/reference/quote-add-products.html + - label: placeOrder mutation + url: /graphql/reference/quote-place-order.html - - label: Update and remove products - url: /graphql/reference/quote-update-remove-products.html + - label: removeCouponFromCart mutation + url: /graphql/reference/quote-remove-coupon.html - - label: Manage coupons - url: /graphql/reference/quote-apply-discount.html + - label: removeItemFromCart mutation + url: /graphql/reference/quote-remove-item.html - - label: Set billing and shipping addresses - url: /graphql/reference/quote-set-addresses.html + - label: setBillingAddressesOnCart mutation + url: /graphql/reference/quote-set-billing-address.html - - label: Set shipping methods - url: /graphql/reference/quote-shipping-method.html + - label: setGuestEmailOnCart mutation + url: /graphql/reference/quote-set-guest-email.html - - label: Set the payment method + - label: setPaymentMethodOnCart mutation url: /graphql/reference/quote-payment-method.html - - label: Place an order - url: /graphql/reference/quote-place-order.html + - label: setShippingAddressesOnCart mutation + url: /graphql/reference/quote-set-shipping-address.html + + - label: setShippingMethodsOnCart mutation + url: /graphql/reference/quote-shipping-method.html + + - label: updateCartItems mutation + url: /graphql/reference/quote-update-cart-items.html - label: Sales endpoint url: /graphql/reference/sales.html diff --git a/guides/v2.3/graphql/reference/quote-add-products.md b/guides/v2.3/graphql/reference/quote-add-products.md deleted file mode 100644 index a5d463731e2..00000000000 --- a/guides/v2.3/graphql/reference/quote-add-products.md +++ /dev/null @@ -1,320 +0,0 @@ ---- -group: graphql -title: Add products to a cart ---- - -This topic describes how to add the following types of products to a cart: - -* Simple -* Virtual - -{:.bs-callout .bs-callout-info} -The mutation for [adding configurable products]({{page.baseurl}}/graphql/reference/configurable-product.html) is defined in the `ConfigurableProductGraphQl` module. - -## Add simple products - -To add a simple product to a cart, you must provide the cart ID, the SKU, and the quantity. You can also optionally provide customizable options. - -### Syntax - -`mutation; {addSimpleProductsToCart(input: AddSimpleProductsToCartInput): AddSimpleProductsToCartOutput}` - -### Example usage - -These examples show the minimal payload and a payload that includes customizable options. - -#### Add a simple product to a cart - -The following example adds a simple product to a cart. The response contains the entire contents of the customer's cart. - -**Request** - -```text -mutation { - addSimpleProductsToCart( - input: { - cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", - cart_items: [ - { - data: { - quantity: 1 - sku: "24-MB04" - } - } - ] - } - ) { - cart { - items { - id - product { - name - sku - } - quantity - } - } - } -} -``` - -**Response** - -```json -{ - "data": { - "addSimpleProductsToCart": { - "cart": { - "items": [ - { - "id": "13", - "product": { - "name": "Strive Shoulder Pack", - "sku": "24-MB04" - }, - "quantity": 1 - } - ] - } - } - } -} -``` - -#### Add a simple product with customizable options to a cart - -If a product has a customizable option, the option's value can be specified in the add to cart request. - -**Request** - -``` text -mutation { - addSimpleProductsToCart (input: { - cart_id: "nu31JXR9DaqbdVqFDGnqjrMJmUnT3mzB" - cart_items: { - data: { - sku: "simple" - quantity: 1 - }, - customizable_options: [ - { - id: 121 - value_string: "field value" - } - ] - } - }) { - cart { - items { - product { - name - } - quantity - - ... on SimpleCartItem { - customizable_options { - label - values { - value - } - } - } - } - } - } -} -``` - -**Response** - -```text -{ - "data": { - "addSimpleProductsToCart": { - "cart": { - "items": [ - { - "product": { - "name": "simple" - }, - "qty": 2, - "customizable_options": [ - { - "label": "Field Option", - "values": [ - { - "value": "field value" - } - ] - } - ] - } - ] - } - } - } -} -``` - -### Input attributes - -The top-level `AddSimpleProductsToCartInput` object is listed first. All child objects are listed in alphabetical order. - -#### AddSimpleProductsToCartInput object {#AddSimpleProductsToCartInput} - -The `AddSimpleProductsToCartInput` object must contain the following attributes: - -Attribute | Data Type | Description ---- | --- | --- -`cart_id` | String! | The unique ID that identifies the customer's cart -`cart_items` | SimpleProductCartItemInput! | Contains the cart item IDs and quantity of each item - -#### CartItemInput object - -The `CartItemInput` object must contain the following attributes: - -{% include graphql/customizable-option-input.md %} - -#### CustomizableOptionInput object - -The `CustomizableOptionInput` object must contain the following attributes: - -{% include graphql/customizable-option-input.md %} - -#### SimpleProductCartItemInput object - -The `SimpleProductCartItemInput` object must contain the following attributes: - -`customizable_options` |[CustomizableOptionInput] | An array that defines customizable options for the product -`data` | CartItemInput! | An object containing the `sku` and `quantity` of the product. - -### Output attributes - -The `AddSimpleProductsToCartOutput` object contains the `Cart` object. - -Attribute | Data Type | Description ---- | --- | --- -`cart` | Cart! | Describes the contents of the specified shopping cart. - -#### Cart object - -{% include graphql/cart-object.md %} - -## Add virtual products - -A virtual product represents a saleable item that is not physical, such as a membership, service, warranty, or subscription. - -### Syntax - -`mutation; {addVirtualProductsToCart(input: AddVirtualProductsToCartInput): AddVirtualProductsToCartOutput}` - -### Example usage - -The Luma sample data does not include any virtual products. The following example requires that you create a virtual product with the `sku` value Membership-Gold with a price of $49.99. - -**Request** - -```text - -mutation { - addVirtualProductsToCart( - input: { - cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", - cart_items: [ - { - data: { - quantity: 1 - sku: "Membership-Gold" - } - } - ] - } - ) { - cart { - items { - product { - name - } - quantity - } - prices { - grand_total { - value - currency - } - } - } - } -} -``` - -**Response** - -```json -{ - "data": { - "addVirtualProductsToCart": { - "cart": { - "items": [ - { - "product": { - "name": "Gold Membership" - }, - "quantity": 1 - } - ], - "prices": { - "grand_total": { - "value": 49.99, - "currency": "USD" - } - } - } - } - } -} -``` - -### Input attributes - -The top-level `AddVirtualProductsToCartInput` object is listed first. All child objects are listed in alphabetical order. - -#### AddVirtualProductsToCartInput object {#AddVirtualProductsToCartInput} - -The `AddVirtualProductsToCartInput` object must contain the following attributes: - -Attribute | Data Type | Description ---- | --- | --- -`cart_id` | String! | The unique ID that identifies the customer's cart -`cart_items` | VirtualProductCartItemInput! | Contains the cart item IDs and quantity of each item - -#### CartItemInput object - -The `CartItemInput` object must contain the following attributes: - -{% include graphql/cart-item-input.md %} - -#### CustomizableOptionInput object - -The `CustomizableOptionInput` object must contain the following attributes: - -{% include graphql/customizable-option-input.md %} - -#### VirtualProductCartItemInput object - -The `VirtualProductCartItemInput` object must contain the following attributes: - -`customizable_options` |[CustomizableOptionInput] | An array that defines customizable options for the product -`data` | CartItemInput! | An object containing the `sku` and `quantity` of the product. - -### Output attributes - -The `AddVirtualProductsToCartOutput` object contains the `Cart` object. - -Attribute | Data Type | Description ---- | --- | --- -`cart` | Cart! | Describes the contents of the specified shopping cart. - -#### Cart object - -{% include graphql/cart-object.md %} \ No newline at end of file diff --git a/guides/v2.3/graphql/reference/quote-add-simple-products.md b/guides/v2.3/graphql/reference/quote-add-simple-products.md new file mode 100644 index 00000000000..6bb1745bdf9 --- /dev/null +++ b/guides/v2.3/graphql/reference/quote-add-simple-products.md @@ -0,0 +1,194 @@ +--- +group: graphql +title: addSimpleProductsToCart mutation +--- + +Simple products are physical products that do not have variations, such as color, size, or price. The `addSimpleProductsToCart` mutation allows you to add multiple simple products to the cart at the same time, but you cannot add other product types with this mutation. To add a simple product to a cart, you must provide the cart ID, the SKU, and the quantity. You can also optionally provide customizable options. + +{:.bs-callout .bs-callout-info} +The mutation for [adding configurable products]({{page.baseurl}}/graphql/reference/configurable-product.html) is defined in the `ConfigurableProductGraphQl` module. + +## Syntax + +`mutation; {addSimpleProductsToCart(input: AddSimpleProductsToCartInput): AddSimpleProductsToCartOutput}` + +## Example usage + +These examples show the minimal payload and a payload that includes customizable options. + +### Add a simple product to a cart + +The following example adds a simple product to a cart. The response contains the entire contents of the customer's cart. + +**Request** + +```text +mutation { + addSimpleProductsToCart( + input: { + cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", + cart_items: [ + { + data: { + quantity: 1 + sku: "24-MB04" + } + } + ] + } + ) { + cart { + items { + id + product { + name + sku + } + quantity + } + } + } +} +``` + +**Response** + +```json +{ + "data": { + "addSimpleProductsToCart": { + "cart": { + "items": [ + { + "id": "13", + "product": { + "name": "Strive Shoulder Pack", + "sku": "24-MB04" + }, + "quantity": 1 + } + ] + } + } + } +} +``` + +### Add a simple product with customizable options to a cart + +If a product has a customizable option, the option's value can be specified in the add to cart request. + +**Request** + +``` text +mutation { + addSimpleProductsToCart (input: { + cart_id: "nu31JXR9DaqbdVqFDGnqjrMJmUnT3mzB" + cart_items: { + data: { + sku: "simple" + quantity: 1 + }, + customizable_options: [ + { + id: 121 + value_string: "field value" + } + ] + } + }) { + cart { + items { + product { + name + } + quantity + + ... on SimpleCartItem { + customizable_options { + label + values { + value + } + } + } + } + } + } +} +``` + +**Response** + +```text +{ + "data": { + "addSimpleProductsToCart": { + "cart": { + "items": [ + { + "product": { + "name": "simple" + }, + "qty": 2, + "customizable_options": [ + { + "label": "Field Option", + "values": [ + { + "value": "field value" + } + ] + } + ] + } + ] + } + } + } +} +``` + +## Input attributes + +The top-level `AddSimpleProductsToCartInput` object is listed first. All child objects are listed in alphabetical order. + +### AddSimpleProductsToCartInput object {#AddSimpleProductsToCartInput} + +The `AddSimpleProductsToCartInput` object must contain the following attributes: + +Attribute | Data Type | Description +--- | --- | --- +`cart_id` | String! | The unique ID that identifies the customer's cart +`cart_items` | [SimpleProductCartItemInput!](#SimpleProductCartItemInput) | Contains the cart item IDs and quantity of each item + +### CartItemInput object {#CartItemInputSimple} + +The `CartItemInput` object must contain the following attributes: + +{% include graphql/customizable-option-input.md %} + +### CustomizableOptionInput object {#CustomizableOptionInputSimple} + +The `CustomizableOptionInput` object must contain the following attributes: + +{% include graphql/customizable-option-input.md %} + +### SimpleProductCartItemInput object {#SimpleProductCartItemInput} + +The `SimpleProductCartItemInput` object must contain the following attributes: + +`customizable_options` |[[CustomizableOptionInputSimple]](#CustomizableOptionInputSimple) | An array that defines customizable options for the product +`data` | [CartItemInput!](#CartItemInputSimple) | An object containing the `sku` and `quantity` of the product. + +## Output attributes + +The `AddSimpleProductsToCartOutput` object contains the `Cart` object. + +Attribute | Data Type | Description +--- | --- | --- +`cart` | Cart! | Describes the contents of the specified shopping cart. + +### Cart object + +{% include graphql/cart-object.md %} \ No newline at end of file diff --git a/guides/v2.3/graphql/reference/quote-add-virtual-products.md b/guides/v2.3/graphql/reference/quote-add-virtual-products.md new file mode 100644 index 00000000000..86d4fcdfe07 --- /dev/null +++ b/guides/v2.3/graphql/reference/quote-add-virtual-products.md @@ -0,0 +1,126 @@ +--- +group: graphql +title: addVirtualProductsToCart mutation +--- + +A virtual product represents a saleable item that is not physical, such as a membership, service, warranty, or subscription. Virtual products do not need to be shipped or downloaded, nor do they require stock management. + +The `addVirtualProductsToCart` mutation allows you to add multiple virtual products to the cart at the same time, but you cannot add other product types with this mutation. To add a virtual product to a cart, you must provide the cart ID, the SKU, and the quantity. You can also optionally provide customizable options. + +{:.bs-callout .bs-callout-info} +The mutation for [adding configurable products]({{page.baseurl}}/graphql/reference/configurable-product.html) is defined in the `ConfigurableProductGraphQl` module. + +## Syntax + +`mutation; {addVirtualProductsToCart(input: AddVirtualProductsToCartInput): AddVirtualProductsToCartOutput}` + +## Example usage + +The Luma sample data does not include any virtual products. The following example requires that you create a virtual product with the `sku` value of `Membership-Gold` with a price of $49.99. + +**Request** + +```text + +mutation { + addVirtualProductsToCart( + input: { + cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", + cart_items: [ + { + data: { + quantity: 1 + sku: "Membership-Gold" + } + } + ] + } + ) { + cart { + items { + product { + name + } + quantity + } + prices { + grand_total { + value + currency + } + } + } + } +} +``` + +**Response** + +```json +{ + "data": { + "addVirtualProductsToCart": { + "cart": { + "items": [ + { + "product": { + "name": "Gold Membership" + }, + "quantity": 1 + } + ], + "prices": { + "grand_total": { + "value": 49.99, + "currency": "USD" + } + } + } + } + } +} +``` + +## Input attributes + +The top-level `AddVirtualProductsToCartInput` object is listed first. All child objects are listed in alphabetical order. + +### AddVirtualProductsToCartInput object {#AddVirtualProductsToCartInput} + +The `AddVirtualProductsToCartInput` object must contain the following attributes: + +Attribute | Data Type | Description +--- | --- | --- +`cart_id` | String! | The unique ID that identifies the customer's cart +`cart_items` | [VirtualProductCartItemInput!](#VirtualProductCartItemInput) | Contains the cart item IDs and quantity of each item + +### CartItemInput object {#CartItemInputVirtual} + +The `CartItemInput` object must contain the following attributes: + +{% include graphql/cart-item-input.md %} + +### CustomizableOptionInput object {#CustomizableOptionInputVirtual} + +The `CustomizableOptionInput` object must contain the following attributes: + +{% include graphql/customizable-option-input.md %} + +### VirtualProductCartItemInput object {#VirtualProductCartItemInput} + +The `VirtualProductCartItemInput` object must contain the following attributes: + +`customizable_options` |[[CustomizableOptionInput]](#CustomizableOptionInputVirtual) | An array that defines customizable options for the product +`data` | [CartItemInput!](#CartItemInputVirtual) | An object containing the `sku` and `quantity` of the product. + +## Output attributes + +The `AddVirtualProductsToCartOutput` object contains the `Cart` object. + +Attribute | Data Type | Description +--- | --- | --- +`cart` | Cart! | Describes the contents of the specified shopping cart. + +### Cart object + +{% include graphql/cart-object.md %} \ No newline at end of file diff --git a/guides/v2.3/graphql/reference/quote-apply-coupon.md b/guides/v2.3/graphql/reference/quote-apply-coupon.md new file mode 100644 index 00000000000..ec0b71cfafe --- /dev/null +++ b/guides/v2.3/graphql/reference/quote-apply-coupon.md @@ -0,0 +1,113 @@ +--- +group: graphql +title: applyCouponToCart mutation +--- + +The `applyCouponToCart` mutation applies a pre-defined coupon code to the specified cart. Valid coupon codes are defined in cart price rules. + +## Syntax + +`mutation: {applyCouponToCart(input: ApplyCouponToCartInput) {ApplyCouponToCartOutput}}` + +## Example usage + +The following example applies the coupon code `H2O` to the cart. For this coupon to be valid, the Affirm Water Bottle (`sku`: 24-UG06) must be in the cart. + +**Request** + +``` text +mutation { + applyCouponToCart( + input: { + cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", + coupon_code: "H20" + } + ) { + cart { + items { + product { + name + } + quantity + } + applied_coupon { + code + } + prices { + grand_total{ + value + currency + } + } + } + } +} +``` + +**Response** + +```json +{ + "data": { + "applyCouponToCart": { + "cart": { + "items": [ + { + "product": { + "name": "Gold Membership" + }, + "quantity": 2 + }, + { + "product": { + "name": "Strive Shoulder Pack" + }, + "quantity": 1 + }, + { + "product": { + "name": "Affirm Water Bottle " + }, + "quantity": 1 + } + ], + "applied_coupon": { + "code": "H20" + }, + "prices": { + "grand_total": { + "value": 134.08, + "currency": "USD" + } + } + } + } + } +} +``` + +## Input attributes + +The `applyCouponToCart` mutation requires the `cart_id` and `coupon_code`. + +### ApplyCouponToCartInput object {#ApplyCouponToCartInput} + +The `ApplyCouponToCartInput` object must contain the following attributes: + +Attribute | Data Type | Description +--- | --- | --- +`cart_id` | String! | The unique ID that identifies the customer's cart +`coupon_code` | String! | A valid coupon code + + +## Output attributes + +The `ApplyCouponToCartOutput` object contains the `Cart` object. + +Attribute | Data Type | Description +--- | --- | --- +`cart` | Cart! | Describes the contents of the specified shopping cart. + +### Cart object + +{% include graphql/cart-object.md %} diff --git a/guides/v2.3/graphql/reference/quote-apply-discount.md b/guides/v2.3/graphql/reference/quote-apply-discount.md deleted file mode 100644 index ca8f2facb34..00000000000 --- a/guides/v2.3/graphql/reference/quote-apply-discount.md +++ /dev/null @@ -1,216 +0,0 @@ ---- -group: graphql -title: Manage coupons ---- - -You can use GraphQL to apply a coupon to a cart or remove a coupon from the same cart. - -## Apply a coupon to a cart - -The `applyCouponToCart` mutation applies a pre-defined coupon code to the specified cart. Valid coupon codes are defined in cart price rules. - -### Syntax - -`mutation: {applyCouponToCart(input: ApplyCouponToCartInput) {ApplyCouponToCartOutput}}` - -### Example usage - -The following example applies the coupon code `H2O` to the cart. For this coupon to be valid, the Affirm Water Bottle (`sku`: 24-UG06) must be in the cart. - -**Request** - -``` text -mutation { - applyCouponToCart( - input: { - cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", - coupon_code: "H20" - } - ) { - cart { - items { - product { - name - } - quantity - } - applied_coupon { - code - } - prices { - grand_total{ - value - currency - } - } - } - } -} -``` - -**Response** - -```json -{ - "data": { - "applyCouponToCart": { - "cart": { - "items": [ - { - "product": { - "name": "Gold Membership" - }, - "quantity": 2 - }, - { - "product": { - "name": "Strive Shoulder Pack" - }, - "quantity": 1 - }, - { - "product": { - "name": "Affirm Water Bottle " - }, - "quantity": 1 - } - ], - "applied_coupon": { - "code": "H20" - }, - "prices": { - "grand_total": { - "value": 134.08, - "currency": "USD" - } - } - } - } - } -} -``` - -### Input attributes - -The `applyCouponToCart` mutation requires the `cart_id` and `coupon_code`. - -#### ApplyCouponToCartInput object {#ApplyCouponToCartInput} - -The `ApplyCouponToCartInput` object must contain the following attributes: - -Attribute | Data Type | Description ---- | --- | --- -`cart_id` | String! | The unique ID that identifies the customer's cart -`coupon_code` | String! | A valid coupon code - - -### Output attributes - -The `ApplyCouponToCartOutput` object contains the `Cart` object. - -Attribute | Data Type | Description ---- | --- | --- -`cart` | Cart! | Describes the contents of the specified shopping cart. - -#### Cart object - -{% include graphql/cart-object.md %} - -## Remove a coupon from a cart - -The `removeCouponFromCart` mutation removes a previously-applied coupon from the cart. - -### Syntax - -`mutation: {removeCouponFromCart(input: RemoveCouponFromCartInput){ RemoveCouponFromCartOutput}}` - -### Example usage - -The following example removes a coupon from the cart. - -**Request** - -``` text -mutation { - removeCouponFromCart( - input: - { cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG" } - ) { - cart { - items { - product { - name - } - quantity - } - applied_coupon { - code - } - prices { - grand_total{ - value - currency - } - } - } - } -} -``` - -**Response** - -```json -{ - "data": { - "removeCouponFromCart": { - "cart": { - "items": [ - { - "product": { - "name": "Strive Shoulder Pack" - }, - "quantity": 1 - }, - { - "product": { - "name": "Affirm Water Bottle " - }, - "quantity": 1 - } - ], - "applied_coupon": null, - "prices": { - "grand_total": { - "value": 39, - "currency": "USD" - } - } - } - } - } -} -``` - -### Input attributes - -The `removeCouponFromCart` mutation requires the `cart_id` attribute. - -#### removeCouponFromCart object {#removeCouponFromCart} - -The `removeCouponFromCart` object must contain the following attributes: - -Attribute | Data Type | Description ---- | --- | --- -`cart_id` | String! | The unique ID that identifies the customer's cart - -### Output attributes - -The `removeCouponFromCart` object contains the `Cart` object. - -Attribute | Data Type | Description ---- | --- | --- -`cart` | Cart! | Describes the contents of the specified shopping cart. - -#### Cart object - -{% include graphql/cart-object.md %} diff --git a/guides/v2.3/graphql/reference/quote-create-cart.md b/guides/v2.3/graphql/reference/quote-create-cart.md index 202465faa8b..75049771410 100644 --- a/guides/v2.3/graphql/reference/quote-create-cart.md +++ b/guides/v2.3/graphql/reference/quote-create-cart.md @@ -1,21 +1,20 @@ --- group: graphql -title: Create an empty cart +title: createEmptyCart mutation --- The `createEmptyCart` mutation creates an empty shopping cart for a guest or logged in customer. You can allow the system to generate a cart ID, or assign a specific ID. If you are creating a cart for a logged in customer, you must include the customer's authorization token in the header of the request. -## Create an empty cart {#createEmptyCart} -The following example creates a cart with a randomly-generated cart ID. - -### Syntax +## Syntax `mutation: {createEmptyCart}: String` -### Example usage +## Example usage + +### Create a cart with a randomly-generated cart ID **Request** @@ -27,7 +26,7 @@ mutation { **Response** -The response is the quote ID, which is sometimes called the cart ID. The remaining examples in this topic will use this cart ID. +The response is the cart ID, which is sometimes called the quote ID. The remaining examples in this topic will use this cart ID. ```json { @@ -37,7 +36,7 @@ The response is the quote ID, which is sometimes called the cart ID. The remaini } ``` -## Create an empty cart with an assigned cart ID +### Create an empty cart with an assigned cart ID You can also create an empty cart with a specified `cart_id`. diff --git a/guides/v2.3/graphql/reference/quote-payment-method.md b/guides/v2.3/graphql/reference/quote-payment-method.md index 05d1489588f..0d2d1a46b90 100644 --- a/guides/v2.3/graphql/reference/quote-payment-method.md +++ b/guides/v2.3/graphql/reference/quote-payment-method.md @@ -1,9 +1,9 @@ --- group: graphql -title: Payment method mutations +title: setPaymentMethodOnCart mutation --- -You can use GraphQL to set the payment method on a cart. GraphQL supports the following payment methods: +The `setPaymentMethodOnCart` mutation defines which payment method to apply to the cart. Magento GraphQL supports the following payment methods: Title | Code --- | --- @@ -13,15 +13,13 @@ Check / Money order | `checkmo` No Payment Information Required | `free` Purchase Order | `purchaseorder` -## Set the payment method {#setPaymentMethodOnCart} +Apply the `setPaymentMethodOnCart` mutation after setting the shipping address and shipping method, and after applying any discounts to the cart. -Apply the `setPaymentMethodOnCart` mutation after setting the shipping address, shipping method and any discounts have been applied to the cart. - -### Syntax +## Syntax `mutation: {setPaymentMethodOnCart(input: SetPaymentMethodOnCartInput): SetPaymentMethodOnCartOutput}}` -### Example usage +## Example usage The following example assigns the `banktransfer` payment method to the specified cart. @@ -34,7 +32,7 @@ mutation { payment_method: { code: "banktransfer" } - }) { + }) { cart { selected_payment_method { code @@ -62,11 +60,11 @@ mutation { } ``` -### Input attributes +## Input attributes The top-level `SetPaymentMethodOnCartInput` object is listed first. All child objects are listed in alphabetical order. -#### SetPaymentMethodOnCartInput attributes {#SetPaymentMethodOnCartInput} +### SetPaymentMethodOnCartInput attributes {#SetPaymentMethodOnCartInput} The `SetPaymentMethodOnCartInput` object must contain the following attributes: @@ -75,7 +73,7 @@ Attribute | Data Type | Description `cart_id` | String! | The unique ID that identifies the customer’s cart `payment_method` | [PaymentMethodInput!](#PaymentMethodInput) | An object containing the payment method code -#### PaymentMethodInput attributes {#PaymentMethodInput} +### PaymentMethodInput attributes {#PaymentMethodInput} The `PaymentMethodInput` object can contain the following attributes: @@ -84,7 +82,7 @@ Attribute | Data Type | Description `code` | String! | The internal name for the payment method `purchase_order_number` | String | The purchase order number. Optional for most payment methods -### Output attributes +## Output attributes The `SetPaymentMethodOnCartOutput` object contains the `Cart` object. @@ -92,7 +90,7 @@ Attribute | Data Type | Description --- | --- | --- `cart` | Cart! | Describes the contents of the specified shopping cart. -#### SetPaymentMethodOnCartOutput attributes {#SetPaymentMethodOnCartOutput} +### SetPaymentMethodOnCartOutput attributes {#SetPaymentMethodOnCartOutput} The `SetPaymentMethodOnCartOutput` object contains the `Cart` object. diff --git a/guides/v2.3/graphql/reference/quote-place-order.md b/guides/v2.3/graphql/reference/quote-place-order.md index f519acf5d2c..f4f55f3fa2d 100644 --- a/guides/v2.3/graphql/reference/quote-place-order.md +++ b/guides/v2.3/graphql/reference/quote-place-order.md @@ -1,90 +1,25 @@ --- group: graphql -title: Place an order +title: placeOrder mutation --- -For guest customers, you must assign an email to the cart before you place the order. - -The email is already associated with a logged-in customer's account. Therefore, you can place the order without setting the email. - -## Set the guest's email on the cart - -The following example sets the guest email. - -### Syntax - -`mutation: {setGuestEmailOnCart(input: SetGuestEmailOnCartInput): {SetGuestEmailOnCartOutput}}` - - -### Example usage - -**Request** - -``` text -mutation { - setGuestEmailOnCart( - input: { - cart_id: "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C" - email: "jdoe@example.com" - } - ) { - cart { - email - } - } -} -``` - -**Response** - -```json -{ - "data": { - "setGuestEmailOnCart": { - "cart": { - "email": "jdoe@example.com" - } - } - } -} -``` - -### Input attributes - -The `SetGuestEmailOnCartInput` object must contain the following attributes. - -Attribute | Data Type | Description ---- | --- | --- -`cart_id` | String! | The unique ID that identifies the customer’s cart -`email` | String! | The guest user's email - -### Output attributes - -The `SetGuestEmailOnCartOutput` object contains the `Cart` object. - -Attribute | Data Type | Description ---- | --- | --- -`cart` | Cart! | Describes the contents of the specified shopping cart. - -#### SetGuestEmailOnCartOutput attributes {#SetGuestEmailOnCartOutput} - -The `SetGuestEmailOnCartOutput` object contains the `Cart` object. - -{% include graphql/cart-object.md %} - -## Place the order - The `placeOrder` mutation converts the cart into an order and returns an order ID. You cannot manage orders with GraphQL, because orders are part of the backend. You can use REST or SOAP calls to manage orders to their completion. -Attribute | Data Type | Description ---- | --- | --- -`cart_id` | String | A 32-character string +Perform the following actions before using the `placeOrder` mutation: + +* Create an empty cart +* Add one or more products to the cart +* Set the billing address +* Set the shipping address +* Set the shipping method +* Set the payment method +* For guest customers, assign an email to the cart -### Syntax +## Syntax `mutation: {placeOrder(input: PlaceOrderInput): {PlaceOrderOutput}}` -### Example usage +## Example usage **Request** @@ -117,7 +52,7 @@ mutation { } ``` -### Input attributes +## Input attributes The `placeOrderInput` object must contain the following attribute: @@ -126,7 +61,7 @@ Attribute | Data Type | Description --- | --- | --- `cart_id` | String! | The unique ID that identifies the customer’s cart -### Output attributes +## Output attributes The `placeOrderOutput` object contains the `order` object, which contains the following attribute: diff --git a/guides/v2.3/graphql/reference/quote-remove-coupon.md b/guides/v2.3/graphql/reference/quote-remove-coupon.md new file mode 100644 index 00000000000..66796f83b8e --- /dev/null +++ b/guides/v2.3/graphql/reference/quote-remove-coupon.md @@ -0,0 +1,101 @@ +--- +group: graphql +title: removeCouponFromCart mutation +--- + +The `removeCouponFromCart` mutation removes a previously-applied coupon from the cart. + +## Syntax + +`mutation: {removeCouponFromCart(input: RemoveCouponFromCartInput){ RemoveCouponFromCartOutput}}` + +## Example usage + +The following example removes a coupon from the cart. + +**Request** + +``` text +mutation { + removeCouponFromCart( + input: + { cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG" } + ) { + cart { + items { + product { + name + } + quantity + } + applied_coupon { + code + } + prices { + grand_total{ + value + currency + } + } + } + } +} +``` + +**Response** + +```json +{ + "data": { + "removeCouponFromCart": { + "cart": { + "items": [ + { + "product": { + "name": "Strive Shoulder Pack" + }, + "quantity": 1 + }, + { + "product": { + "name": "Affirm Water Bottle " + }, + "quantity": 1 + } + ], + "applied_coupon": null, + "prices": { + "grand_total": { + "value": 39, + "currency": "USD" + } + } + } + } + } +} +``` + +## Input attributes + +The `removeCouponFromCart` mutation requires the `cart_id` attribute. + +### removeCouponFromCart object {#removeCouponFromCart} + +The `removeCouponFromCart` object must contain the following attributes: + +Attribute | Data Type | Description +--- | --- | --- +`cart_id` | String! | The unique ID that identifies the customer's cart + +## Output attributes + +The `removeCouponFromCart` object contains the `Cart` object. + +Attribute | Data Type | Description +--- | --- | --- +`cart` | Cart! | Describes the contents of the specified shopping cart. + +### Cart object + +{% include graphql/cart-object.md %} diff --git a/guides/v2.3/graphql/reference/quote-remove-item.md b/guides/v2.3/graphql/reference/quote-remove-item.md new file mode 100644 index 00000000000..aaa32c79351 --- /dev/null +++ b/guides/v2.3/graphql/reference/quote-remove-item.md @@ -0,0 +1,93 @@ +--- +group: graphql +title: removeItemFromCart mutation +--- + +The `removeItemFromCart` mutation deletes the entire quantity of a specified item from the cart. If you remove all items from the cart, the cart continues to exist. + +## Syntax + +`mutation; {removeItemFromCart(input: RemoveItemFromCartInput): RemoveItemFromCartOutput}` + +## Example usage + +The following example removes cart item 14 from the cart. + +**Request** + +```text +mutation { + removeItemFromCart( + input: { + cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", + cart_item_id: 14 + } + ){ + cart { + items { + id + product { + name + } + quantity + } + prices { + grand_total{ + value + currency + } + } + } +} +``` + +**Response** + +```json +{ + "data": { + "removeItemFromCart": { + "cart": { + "items": [ + { + "id": "13", + "product": { + "name": "Strive Shoulder Pack" + }, + "quantity": 3 + } + ], + "prices": { + "grand_total": { + "value": 96, + "currency": "USD" + } + } + } + } + } +} +``` + +## Input attributes + +### RemoveItemFromCartInput object {#RemoveItemFromCartInput} + +The `RemoveItemFromCartInput` object must contain the following attributes: + +Attribute | Data Type | Description +--- | --- | --- +`cart_id` | String! | The unique ID that identifies the customer's cart +`cart_item_id` | Int! | The unique ID assigned when a customer places an item in the cart + +## Output attributes + +The `UpdateCartItemsOutut` object contains the `Cart` object. + +Attribute | Data Type | Description +--- | --- | --- +`cart` | Cart! | Describes the contents of the specified shopping cart. + +### Cart object + +{% include graphql/cart-object.md %} \ No newline at end of file diff --git a/guides/v2.3/graphql/reference/quote-set-addresses.md b/guides/v2.3/graphql/reference/quote-set-addresses.md deleted file mode 100644 index 199887d0fd4..00000000000 --- a/guides/v2.3/graphql/reference/quote-set-addresses.md +++ /dev/null @@ -1,233 +0,0 @@ ---- -group: graphql -title: Set billing and shipping addresses ---- - -Magento GraphQL supports billing and shipping addresses, including address books. - -## Set the billing address - -Use the `setBillingAddressOnCart` mutation to set a new billing address for a specific cart. - -If you set the `use_for_shipping` attribute to `true`, Magento assigns the same address as the shipping address. - -### Syntax - -`mutation: {setBillingAddressOnCart(input: SetBillingAddressOnCartInput) {SetBillingAddressOnCartOutput}}` - -### Example usage - -The following example creates a new billing address for a specific cart. - -**Request** - -``` text -mutation { - setBillingAddressOnCart( - input: { - cart_id: "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C" - billing_address: { - address: { - firstname: "Bob" - lastname: "Roll" - company: "Magento" - street: ["Magento Pkwy", "Main Street"] - city: "Austin" - region: "TX" - postcode: "78758" - country_code: "US" - telephone: "8675309" - save_in_address_book: true - } - use_for_shipping: false - } - } - ) { - cart { - billing_address { - firstname - lastname - company - street - city - postcode - telephone - } - } - } -} -``` - -**Response** - -```json -{ - "data": { - "setBillingAddressOnCart": { - "cart": { - "billing_address": { - "firstname": "Bob", - "lastname": "Roll", - "company": "Magento", - "street": [ - "Magento Pkwy", - "Main Street" - ], - "city": "Austin", - "postcode": "78758", - "telephone": "8675309" - } - } - } - } -} -``` - -### Input attributes - -The top-level `SetBillingAddressOnCartInput` object is listed first. All child objects are listed in alphabetical order. - -#### SetBillingAddressOnCartInput object {#SetBillingAddressOnCartInput} - -Attribute | Data Type | Description ---- | --- | --- -`billing_address` | [BillingAddressInput!](#BillingAddressInput) | The billing address for a specific cart -`cart_id` | String! | The unique ID that identifies the customer's cart - -#### BillingAddressInput object {#BillingAddressInput} - -Attribute | Data Type | Description ---- | --- | --- -`address` | [CartAddressInput](#CartAddressInput) | The billing address for the cart -`customer_address_id` | Int | The unique ID that identifies the customer's address -`use_for_shipping` | Boolean | Specifies whether to use the billing address for the shipping address (`True`/`False`) - -#### CartAddressInput object {#CartAddressInput} - -{% include graphql/cart-address-input.md %} - -### Output attributes - -The `SetBillingAddressOnCartOutput` object contains the `Cart` object. - -Attribute | Data Type | Description ---- | --- | --- -`cart` | Cart! | Describes the contents of the specified shopping cart. - -#### Cart object - -{% include graphql/cart-object.md %} - -## Set shipping addresses - -Use the `setShippingAddressesOnCart` mutation to set one or more shipping addresses on a specific cart. - -### Syntax - -`mutation: {setShippingAddressesOnCart(input: SetShippingAddressesOnCartInput) {SetShippingAddressesOnCartOutput}}` - -### Example usage - -The following example sets a shipping address for a specific cart. - -**Request** - -``` text -mutation { - setShippingAddressesOnCart( - input: { - cart_id: "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C" - shipping_addresses: [ - { - address: { - firstname: "Bob" - lastname: "Roll" - company: "Magento" - street: ["Magento Pkwy", "Main Street"] - city: "Austin" - region: "TX" - postcode: "78758" - country_code: "US" - telephone: "8675309" - save_in_address_book: false - } - } - ] - } - ) { - cart { - shipping_addresses { - firstname - lastname - company - street - city - postcode - telephone - } - } - } -} -``` - -**Response** - -```json -{ - "data": { - "setShippingAddressesOnCart": { - "cart": { - "shipping_addresses": [ - { - "firstname": "Bob", - "lastname": "Roll", - "company": "Magento", - "street": [ - "Magento Pkwy", - "Main Street" - ], - "city": "Austin", - "postcode": "78758", - "telephone": "8675309" - } - ] - } - } - } -} -``` - -### Input attributes - -The top-level `SetShippingAddressesOnCartInput` object is listed first. All child objects are listed in alphabetical order. - -#### SetShippingAddressesOnCartInput object {#SetShippingAddressesOnCartInput} - -Attribute | Data Type | Description ---- | --- | --- -`cart_id` | String! | The unique ID that identifies the customer's cart -`billing_address` | [ShippingAddressInput!](#ShippingAddressInput) | The billing address for a specific cart - -#### CartAddressInput object {#CartAddressInputShip} - -{% include graphql/cart-address-input.md %} - -#### ShippingAddressInput object {#ShippingAddressInput} - -Attribute | Data Type | Description ---- | --- | --- -`address` | [CartAddressInput](#CartAddressInputShip) | The shipping address for the cart -`customer_address_id` | Int | The unique ID that identifies the customer's address - - -### Output attributes - -The `SetShippingAddressOnCartOutput` object contains the `Cart` object. - -Attribute | Data Type | Description ---- | --- | --- -`cart` | Cart! | Describes the contents of the specified shopping cart. - -#### Cart object - -{% include graphql/cart-object.md %} diff --git a/guides/v2.3/graphql/reference/quote-set-billing-address.md b/guides/v2.3/graphql/reference/quote-set-billing-address.md new file mode 100644 index 00000000000..57d01538a64 --- /dev/null +++ b/guides/v2.3/graphql/reference/quote-set-billing-address.md @@ -0,0 +1,113 @@ +--- +group: graphql +title: setBillingAddressOnCart mutation +--- + +The `setBillingAddressOnCart` mutation sets the billing address for a specific cart. If you set the `use_for_shipping` attribute to `true`, Magento assigns the same address as the shipping address. + +## Syntax + +`mutation: {setBillingAddressOnCart(input: SetBillingAddressOnCartInput) {SetBillingAddressOnCartOutput}}` + +## Example usage + +The following example creates a new billing address for a specific cart. + +**Request** + +``` text +mutation { + setBillingAddressOnCart( + input: { + cart_id: "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C" + billing_address: { + address: { + firstname: "Bob" + lastname: "Roll" + company: "Magento" + street: ["Magento Pkwy", "Main Street"] + city: "Austin" + region: "TX" + postcode: "78758" + country_code: "US" + telephone: "8675309" + save_in_address_book: true + } + use_for_shipping: false + } + } + ) { + cart { + billing_address { + firstname + lastname + company + street + city + postcode + telephone + } + } + } +} +``` + +**Response** + +```json +{ + "data": { + "setBillingAddressOnCart": { + "cart": { + "billing_address": { + "firstname": "Bob", + "lastname": "Roll", + "company": "Magento", + "street": [ + "Magento Pkwy", + "Main Street" + ], + "city": "Austin", + "postcode": "78758", + "telephone": "8675309" + } + } + } + } +} +``` + +## Input attributes + +The top-level `SetBillingAddressOnCartInput` object is listed first. All child objects are listed in alphabetical order. + +### SetBillingAddressOnCartInput object {#SetBillingAddressOnCartInput} + +Attribute | Data Type | Description +--- | --- | --- +`billing_address` | [BillingAddressInput!](#BillingAddressInput) | The billing address for a specific cart +`cart_id` | String! | The unique ID that identifies the customer's cart + +### BillingAddressInput object {#BillingAddressInput} + +Attribute | Data Type | Description +--- | --- | --- +`address` | [CartAddressInput](#CartAddressInput) | The billing address for the cart +`customer_address_id` | Int | The unique ID that identifies the customer's address +`use_for_shipping` | Boolean | Specifies whether to use the billing address for the shipping address (`True`/`False`) + +### CartAddressInput object {#CartAddressInput} + +{% include graphql/cart-address-input.md %} + +## Output attributes + +The `SetBillingAddressOnCartOutput` object contains the `Cart` object. + +Attribute | Data Type | Description +--- | --- | --- +`cart` | Cart! | Describes the contents of the specified shopping cart. + +### Cart object + +{% include graphql/cart-object.md %} diff --git a/guides/v2.3/graphql/reference/quote-set-guest-email.md b/guides/v2.3/graphql/reference/quote-set-guest-email.md new file mode 100644 index 00000000000..475d9fb41f6 --- /dev/null +++ b/guides/v2.3/graphql/reference/quote-set-guest-email.md @@ -0,0 +1,68 @@ +--- +group: graphql +title: setGuestEmailOnCart mutation +--- + +For guest customers, you must assign an email to the cart before you place the order. + +A logged-in customer specifies an email addresses when they create an account. Therefore, you can place the order without explicitly setting the email. + +## Syntax + +`mutation: {setGuestEmailOnCart(input: SetGuestEmailOnCartInput): {SetGuestEmailOnCartOutput}}` + +## Example usage + +**Request** + +``` text +mutation { + setGuestEmailOnCart( + input: { + cart_id: "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C" + email: "jdoe@example.com" + } + ) { + cart { + email + } + } +} +``` + +**Response** + +```json +{ + "data": { + "setGuestEmailOnCart": { + "cart": { + "email": "jdoe@example.com" + } + } + } +} +``` + +## Input attributes + +The `SetGuestEmailOnCartInput` object must contain the following attributes. + +Attribute | Data Type | Description +--- | --- | --- +`cart_id` | String! | The unique ID that identifies the customer’s cart +`email` | String! | The guest user's email + +## Output attributes + +The `SetGuestEmailOnCartOutput` object contains the `Cart` object. + +Attribute | Data Type | Description +--- | --- | --- +`cart` | Cart! | Describes the contents of the specified shopping cart. + +### SetGuestEmailOnCartOutput attributes {#SetGuestEmailOnCartOutput} + +The `SetGuestEmailOnCartOutput` object contains the `Cart` object. + +{% include graphql/cart-object.md %} \ No newline at end of file diff --git a/guides/v2.3/graphql/reference/quote-set-shipping-address.md b/guides/v2.3/graphql/reference/quote-set-shipping-address.md new file mode 100644 index 00000000000..c277d0971e0 --- /dev/null +++ b/guides/v2.3/graphql/reference/quote-set-shipping-address.md @@ -0,0 +1,117 @@ +--- +group: graphql +title: setShippingAddressesOnCart mutation +--- + +The `setShippingAddressesOnCart` mutation sets one or more shipping addresses on a specific cart. The shipping address does not need to be specified in the following circumstances + +* The cart contains only virtual items +* When you defined the billing address, you set the `use_for_shipping` attribute to `true`. Magento assigns the same address as the shipping address. + +## Syntax + +`mutation: {setShippingAddressesOnCart(input: SetShippingAddressesOnCartInput) {SetShippingAddressesOnCartOutput}}` + +## Example usage + +**Request** + +``` text +mutation { + setShippingAddressesOnCart( + input: { + cart_id: "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C" + shipping_addresses: [ + { + address: { + firstname: "Bob" + lastname: "Roll" + company: "Magento" + street: ["Magento Pkwy", "Main Street"] + city: "Austin" + region: "TX" + postcode: "78758" + country_code: "US" + telephone: "8675309" + save_in_address_book: false + } + } + ] + } + ) { + cart { + shipping_addresses { + firstname + lastname + company + street + city + postcode + telephone + } + } + } +} +``` + +**Response** + +```json +{ + "data": { + "setShippingAddressesOnCart": { + "cart": { + "shipping_addresses": [ + { + "firstname": "Bob", + "lastname": "Roll", + "company": "Magento", + "street": [ + "Magento Pkwy", + "Main Street" + ], + "city": "Austin", + "postcode": "78758", + "telephone": "8675309" + } + ] + } + } + } +} +``` + +## Input attributes + +The top-level `SetShippingAddressesOnCartInput` object is listed first. All child objects are listed in alphabetical order. + +### SetShippingAddressesOnCartInput object {#SetShippingAddressesOnCartInput} + +Attribute | Data Type | Description +--- | --- | --- +`cart_id` | String! | The unique ID that identifies the customer's cart +`billing_address` | [ShippingAddressInput!](#ShippingAddressInput) | The billing address for a specific cart + +### CartAddressInput object {#CartAddressInputShip} + +{% include graphql/cart-address-input.md %} + +### ShippingAddressInput object {#ShippingAddressInput} + +Attribute | Data Type | Description +--- | --- | --- +`address` | [CartAddressInput](#CartAddressInputShip) | The shipping address for the cart +`customer_address_id` | Int | The unique ID that identifies the customer's address + + +## Output attributes + +The `SetShippingAddressOnCartOutput` object contains the `Cart` object. + +Attribute | Data Type | Description +--- | --- | --- +`cart` | Cart! | Describes the contents of the specified shopping cart. + +### Cart object + +{% include graphql/cart-object.md %} diff --git a/guides/v2.3/graphql/reference/quote-shipping-method.md b/guides/v2.3/graphql/reference/quote-shipping-method.md index 00cf86b2811..40f4a85820c 100644 --- a/guides/v2.3/graphql/reference/quote-shipping-method.md +++ b/guides/v2.3/graphql/reference/quote-shipping-method.md @@ -1,11 +1,9 @@ --- group: graphql -title: Set shipping methods +title: setShippingMethodsOnCart mutation --- -## Set shipping methods - -Use the `setShippingMethodsOnCart` mutation to set one or more shipping methods on a cart. By default, Magento GraphQL supports the following shipping methods: +The `setShippingMethodsOnCart` mutation sets one or more shipping methods on a cart. By default, Magento GraphQL supports the following shipping methods: Label | Carrier code | Method code --- | --- | --- @@ -17,11 +15,11 @@ Best Way | tablerate | bestway United Parcel Service | ups | Varies United States Postal Service | usps | Varies -### Syntax +## Syntax `mutation: {setShippingMethodsOnCart(input: setShippingMethodsOnCartInput) {setShippingMethodsOnCartOutput}}` -### Example usage +## Example usage The following example sets the shipping method to Best Way. @@ -85,25 +83,25 @@ mutation { } ``` -### Input attributes +## Input attributes The top-level `setShippingMethodsOnCartInput` object is listed first. All child objects are listed in alphabetical order. -#### setShippingMethodsOnCartInput object {#setShippingMethodsOnCartInput} +### setShippingMethodsOnCartInput object {#setShippingMethodsOnCartInput} Attribute | Data Type | Description --- | --- | --- `cart_id` | String! | The unique ID that identifies the customer's cart `shipping_methods` | [ShippingMethodInput!](#ShippingMethodInput) | The billing address for a specific cart -#### ShippingMethodInput object {#ShippingMethodInput} +### ShippingMethodInput object {#ShippingMethodInput} Attribute | Data Type | Description --- | --- | --- `carrier_code` | String! | A string that identifies a commercial carrier or an offline shipping method `method_code` | String! | A string that indicates which service a commercial carrier will use to ship items. For offline shipping methods, this value is similar to the label displayed on the checkout page -### Output attributes +## Output attributes The `ShippingMethodInput` object contains the `Cart` object. @@ -111,6 +109,6 @@ Attribute | Data Type | Description --- | --- | --- `cart` | Cart! | Describes the contents of the specified shopping cart. -#### Cart object +### Cart object {% include graphql/cart-object.md %} diff --git a/guides/v2.3/graphql/reference/quote-update-cart-items.md b/guides/v2.3/graphql/reference/quote-update-cart-items.md new file mode 100644 index 00000000000..d4d08f6e195 --- /dev/null +++ b/guides/v2.3/graphql/reference/quote-update-cart-items.md @@ -0,0 +1,119 @@ +--- +group: graphql +title: updateCartItems mutation +--- + +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. + +{:.bs-callout .bs-callout-info} +Setting the quantity to 0 removes an item from the cart. + +## Syntax + +`mutation; {updateCartItems(input: UpdateCartItemsInput): UpdateCartItemsOutput}` + +## Example usage + +The following example changes the quantity of cart item 13 to 3. + +**Request** + +```text +mutation { + updateCartItems( + input: { + cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", + cart_items: [ + { + cart_item_id: 13 + quantity: 3 + } + ] + } + ){ + cart { + items { + id + product { + name + } + quantity + } + prices { + grand_total{ + value + currency + } + } + } +} +``` + +**Response** + +```json +{ + "data": { + "updateCartItems": { + "cart": { + "items": [ + { + "id": "13", + "product": { + "name": "Strive Shoulder Pack" + }, + "quantity": 3 + }, + { + "id": "14", + "product": { + "name": "Affirm Water Bottle " + }, + "quantity": 1 + } + ], + "prices": { + "grand_total": { + "value": 103, + "currency": "USD" + } + } + } + } + } +} +``` + +## Input attributes + +The `UpdateCartItemsInput` object is listed first. All child objects are listed in alphabetical order. + +### UpdateCartItemsInput object {#UpdateCartItemsInput} + +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} + +The `CartItemUpdateInput` object must 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 +`quantity` | Float! | The new quantity of the item. A value of 0 removes the item from the cart. + +## Output attributes + +The `UpdateCartItemsOutput` object contains the `Cart` object. + +Attribute | Data Type | Description +--- | --- | --- +`cart` | Cart! | Describes the contents of the specified shopping cart. + +### Cart object + +{% include graphql/cart-object.md %} diff --git a/guides/v2.3/graphql/reference/quote-update-remove-products.md b/guides/v2.3/graphql/reference/quote-update-remove-products.md deleted file mode 100644 index 4738b327823..00000000000 --- a/guides/v2.3/graphql/reference/quote-update-remove-products.md +++ /dev/null @@ -1,214 +0,0 @@ ---- -group: graphql -title: Update and remove products ---- - -Use the `updateCartItems` and `removeItemFromCart` mutations to manage the quantity of items in the cart. - -## Update cart items - -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. - -{:.bs-callout .bs-callout-info} -Setting the quantity to 0 removes an item from the cart. - -### Syntax - -`mutation; {updateCartItems(input: UpdateCartItemsInput): UpdateCartItemsOutput}` - -### Example usage - -The following example changes the quantity of cart item 13 to 3. - -**Request** - -```text -mutation { - updateCartItems( - input: { - cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", - cart_items: [ - { - cart_item_id: 13 - quantity: 3 - } - ] - } - ){ - cart { - items { - id - product { - name - } - quantity - } - prices { - grand_total{ - value - currency - } - } - } -} -``` - -**Response** - -```json -{ - "data": { - "updateCartItems": { - "cart": { - "items": [ - { - "id": "13", - "product": { - "name": "Strive Shoulder Pack" - }, - "quantity": 3 - }, - { - "id": "14", - "product": { - "name": "Affirm Water Bottle " - }, - "quantity": 1 - } - ], - "prices": { - "grand_total": { - "value": 103, - "currency": "USD" - } - } - } - } - } -} -``` - -### Input attributes - -The `UpdateCartItemsInput` object is listed first. All child objects are listed in alphabetical order. - -#### UpdateCartItemsInput object {#UpdateCartItemsInput} - -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! | Contains the cart item IDs and quantity of each item - -#### CartItemUpdateInput object - -The `CartItemUpdateInput` object must 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 -`quantity` | Float! | The new quantity of the item. A value of 0 removes the item from the cart. - -### Output attributes - -The `UpdateCartItemsOutut` object contains the `Cart` object. - -Attribute | Data Type | Description ---- | --- | --- -`cart` | Cart! | Describes the contents of the specified shopping cart. - -#### Cart object - -{% include graphql/cart-object.md %} - -## Remove items from a cart - -The `removeItemFromCart` mutation deletes the entire quantity of a specified item from the cart. If you remove all items from the cart, the cart continues to exist. - -### Syntax - -`mutation; {removeItemFromCart(input: RemoveItemFromCartInput): RemoveItemFromCartOutput}` - -### Example usage - -The following example removes cart item 14 from the cart. - -**Request** - -```text -mutation { - removeItemFromCart( - input: { - cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", - cart_item_id: 14 - } - ){ - cart { - items { - id - product { - name - } - quantity - } - prices { - grand_total{ - value - currency - } - } - } -} -``` - -**Response** - -```json -{ - "data": { - "removeItemFromCart": { - "cart": { - "items": [ - { - "id": "13", - "product": { - "name": "Strive Shoulder Pack" - }, - "quantity": 3 - } - ], - "prices": { - "grand_total": { - "value": 96, - "currency": "USD" - } - } - } - } - } -} -``` - -### Input attributes - -#### RemoveItemFromCartInput object {#RemoveItemFromCartInput} - -The `RemoveItemFromCartInput` object must contain the following attributes: - -Attribute | Data Type | Description ---- | --- | --- -`cart_id` | String! | The unique ID that identifies the customer's cart -`cart_item_id` | Int! | The unique ID assigned when a customer places an item in the cart - -### Output attributes - -The `UpdateCartItemsOutut` object contains the `Cart` object. - -Attribute | Data Type | Description ---- | --- | --- -`cart` | Cart! | Describes the contents of the specified shopping cart. - -#### Cart object - -{% include graphql/cart-object.md %} \ No newline at end of file diff --git a/guides/v2.3/graphql/reference/quote.md b/guides/v2.3/graphql/reference/quote.md index 9232e17912a..90d2154b124 100644 --- a/guides/v2.3/graphql/reference/quote.md +++ b/guides/v2.3/graphql/reference/quote.md @@ -573,13 +573,4 @@ Attribute | Data Type | Description ## Mutations -The following topics describe the mutations defined in the `QuoteGraphQl` module: - -* [Create a cart]({{page.baseurl}}/graphql/reference/quote-create-cart.html) -* [Add products to a cart]({{page.baseurl}}/graphql/reference/quote-add-products.html) -* [Update and remove products]({{page.baseurl}}/graphql/reference/quote-update-remove-products.html) -* [Manage coupons]({{page.baseurl}}/graphql/reference/quote-apply-discount.html) -* [Set billing and shipping addresses]({{page.baseurl}}/graphql/reference/quote-set-addresses.html) -* [Set shipping methods]({{page.baseurl}}/graphql/reference/quote-shipping-method.html) -* [Set the payment method]({{page.baseurl}}/graphql/reference/quote-payment-method.html) -* [Place an order]({{page.baseurl}}/graphql/reference/quote-place-order.html) +Refer to the left navigation for information about the mutations defined in the `QuoteGraphQl` module. \ No newline at end of file From b3375b648cbae2509e9c0b55f36a0a1afcc179da Mon Sep 17 00:00:00 2001 From: Kevin Harper Date: Mon, 13 May 2019 17:37:24 -0500 Subject: [PATCH 4/6] Add consistency between topics --- .../reference/quote-add-simple-products.md | 17 +++++++++-------- .../reference/quote-add-virtual-products.md | 10 ++++++---- .../graphql/reference/quote-apply-coupon.md | 6 ++++-- .../v2.3/graphql/reference/quote-create-cart.md | 2 +- .../graphql/reference/quote-payment-method.md | 8 ++++---- .../graphql/reference/quote-remove-coupon.md | 8 +++++--- .../v2.3/graphql/reference/quote-remove-item.md | 12 +++++++----- .../reference/quote-set-billing-address.md | 6 ++++-- .../graphql/reference/quote-set-guest-email.md | 8 ++++---- .../reference/quote-set-shipping-address.md | 6 ++++-- .../graphql/reference/quote-shipping-method.md | 8 +++++--- .../reference/quote-update-cart-items.md | 8 +++++--- guides/v2.3/graphql/reference/quote.md | 5 +++-- 13 files changed, 61 insertions(+), 43 deletions(-) diff --git a/guides/v2.3/graphql/reference/quote-add-simple-products.md b/guides/v2.3/graphql/reference/quote-add-simple-products.md index 6bb1745bdf9..6ea57fb0b56 100644 --- a/guides/v2.3/graphql/reference/quote-add-simple-products.md +++ b/guides/v2.3/graphql/reference/quote-add-simple-products.md @@ -10,7 +10,7 @@ The mutation for [adding configurable products]({{page.baseurl}}/graphql/referen ## Syntax -`mutation; {addSimpleProductsToCart(input: AddSimpleProductsToCartInput): AddSimpleProductsToCartOutput}` +`mutation: {addSimpleProductsToCart(input: AddSimpleProductsToCartInput): {AddSimpleProductsToCartOutput}}` ## Example usage @@ -26,7 +26,7 @@ The following example adds a simple product to a cart. The response contains the mutation { addSimpleProductsToCart( input: { - cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", + cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", cart_items: [ { data: { @@ -83,7 +83,7 @@ If a product has a customizable option, the option's value can be specified in t ``` text mutation { addSimpleProductsToCart (input: { - cart_id: "nu31JXR9DaqbdVqFDGnqjrMJmUnT3mzB" + cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG", cart_items: { data: { sku: "simple" @@ -103,7 +103,6 @@ mutation { name } quantity - ... on SimpleCartItem { customizable_options { label @@ -130,7 +129,7 @@ mutation { "product": { "name": "simple" }, - "qty": 2, + "quantity": 1, "customizable_options": [ { "label": "Field Option", @@ -187,8 +186,10 @@ The `AddSimpleProductsToCartOutput` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` | Cart! | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. + +### Cart object {#CartObject} -### Cart object +{% include graphql/cart-object.md %} -{% include graphql/cart-object.md %} \ No newline at end of file +[Cart query output]({{page.baseurl}}/graphql/reference/quote.html#cart-output) provides more information about the `Cart` object. diff --git a/guides/v2.3/graphql/reference/quote-add-virtual-products.md b/guides/v2.3/graphql/reference/quote-add-virtual-products.md index 86d4fcdfe07..c0c18dd2c20 100644 --- a/guides/v2.3/graphql/reference/quote-add-virtual-products.md +++ b/guides/v2.3/graphql/reference/quote-add-virtual-products.md @@ -12,7 +12,7 @@ The mutation for [adding configurable products]({{page.baseurl}}/graphql/referen ## Syntax -`mutation; {addVirtualProductsToCart(input: AddVirtualProductsToCartInput): AddVirtualProductsToCartOutput}` +`mutation: {addVirtualProductsToCart(input: AddVirtualProductsToCartInput): {AddVirtualProductsToCartOutput}}` ## Example usage @@ -119,8 +119,10 @@ The `AddVirtualProductsToCartOutput` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` | Cart! | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. -### Cart object +### Cart object {#CartObject} -{% include graphql/cart-object.md %} \ No newline at end of file +{% include graphql/cart-object.md %} + +[Cart query output]({{page.baseurl}}/graphql/reference/quote.html#cart-output) provides more information about the `Cart` object. diff --git a/guides/v2.3/graphql/reference/quote-apply-coupon.md b/guides/v2.3/graphql/reference/quote-apply-coupon.md index ec0b71cfafe..f1ca07eadc7 100644 --- a/guides/v2.3/graphql/reference/quote-apply-coupon.md +++ b/guides/v2.3/graphql/reference/quote-apply-coupon.md @@ -106,8 +106,10 @@ The `ApplyCouponToCartOutput` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` | Cart! | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. -### Cart object +### Cart object {#CartObject} {% include graphql/cart-object.md %} + +[Cart query output]({{page.baseurl}}/graphql/reference/quote.html#cart-output) provides more information about the `Cart` object. diff --git a/guides/v2.3/graphql/reference/quote-create-cart.md b/guides/v2.3/graphql/reference/quote-create-cart.md index 75049771410..51a89a7f981 100644 --- a/guides/v2.3/graphql/reference/quote-create-cart.md +++ b/guides/v2.3/graphql/reference/quote-create-cart.md @@ -18,7 +18,7 @@ If you are creating a cart for a logged in customer, you must include the custom **Request** -``` text +```text mutation { createEmptyCart } diff --git a/guides/v2.3/graphql/reference/quote-payment-method.md b/guides/v2.3/graphql/reference/quote-payment-method.md index 0d2d1a46b90..71a2aded6ab 100644 --- a/guides/v2.3/graphql/reference/quote-payment-method.md +++ b/guides/v2.3/graphql/reference/quote-payment-method.md @@ -88,10 +88,10 @@ The `SetPaymentMethodOnCartOutput` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` | Cart! | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. -### SetPaymentMethodOnCartOutput attributes {#SetPaymentMethodOnCartOutput} +### Cart object {#CartObject} -The `SetPaymentMethodOnCartOutput` object contains the `Cart` object. +{% include graphql/cart-object.md %} -{% include graphql/cart-object.md %} \ No newline at end of file +[Cart query output]({{page.baseurl}}/graphql/reference/quote.html#cart-output) provides more information about the `Cart` object. \ No newline at end of file diff --git a/guides/v2.3/graphql/reference/quote-remove-coupon.md b/guides/v2.3/graphql/reference/quote-remove-coupon.md index 66796f83b8e..4c47e993d91 100644 --- a/guides/v2.3/graphql/reference/quote-remove-coupon.md +++ b/guides/v2.3/graphql/reference/quote-remove-coupon.md @@ -7,7 +7,7 @@ The `removeCouponFromCart` mutation removes a previously-applied coupon from the ## Syntax -`mutation: {removeCouponFromCart(input: RemoveCouponFromCartInput){ RemoveCouponFromCartOutput}}` +`mutation: {removeCouponFromCart(input: RemoveCouponFromCartInput) {RemoveCouponFromCartOutput}}` ## Example usage @@ -94,8 +94,10 @@ The `removeCouponFromCart` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` | Cart! | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. -### Cart object +### Cart object {#CartObject} {% include graphql/cart-object.md %} + +[Cart query output]({{page.baseurl}}/graphql/reference/quote.html#cart-output) provides more information about the `Cart` object. diff --git a/guides/v2.3/graphql/reference/quote-remove-item.md b/guides/v2.3/graphql/reference/quote-remove-item.md index aaa32c79351..c92fea9f047 100644 --- a/guides/v2.3/graphql/reference/quote-remove-item.md +++ b/guides/v2.3/graphql/reference/quote-remove-item.md @@ -7,7 +7,7 @@ The `removeItemFromCart` mutation deletes the entire quantity of a specified ite ## Syntax -`mutation; {removeItemFromCart(input: RemoveItemFromCartInput): RemoveItemFromCartOutput}` +`mutation: {removeItemFromCart(input: RemoveItemFromCartInput): {RemoveItemFromCartOutput}}` ## Example usage @@ -82,12 +82,14 @@ Attribute | Data Type | Description ## Output attributes -The `UpdateCartItemsOutut` object contains the `Cart` object. +The `RemoveItemFromCartOutput` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` | Cart! | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. -### Cart object +### Cart object {#CartObject} -{% include graphql/cart-object.md %} \ No newline at end of file +{% include graphql/cart-object.md %} + +[Cart query output]({{page.baseurl}}/graphql/reference/quote.html#cart-output) provides more information about the `Cart` object. \ No newline at end of file diff --git a/guides/v2.3/graphql/reference/quote-set-billing-address.md b/guides/v2.3/graphql/reference/quote-set-billing-address.md index 57d01538a64..43a62e08046 100644 --- a/guides/v2.3/graphql/reference/quote-set-billing-address.md +++ b/guides/v2.3/graphql/reference/quote-set-billing-address.md @@ -106,8 +106,10 @@ The `SetBillingAddressOnCartOutput` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` | Cart! | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. -### Cart object +### Cart object {#CartObject} {% include graphql/cart-object.md %} + +[Cart query output]({{page.baseurl}}/graphql/reference/quote.html#cart-output) provides more information about the `Cart` object. diff --git a/guides/v2.3/graphql/reference/quote-set-guest-email.md b/guides/v2.3/graphql/reference/quote-set-guest-email.md index 475d9fb41f6..0a710a2bd3a 100644 --- a/guides/v2.3/graphql/reference/quote-set-guest-email.md +++ b/guides/v2.3/graphql/reference/quote-set-guest-email.md @@ -59,10 +59,10 @@ The `SetGuestEmailOnCartOutput` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` | Cart! | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. -### SetGuestEmailOnCartOutput attributes {#SetGuestEmailOnCartOutput} +### Cart object {#CartObject} -The `SetGuestEmailOnCartOutput` object contains the `Cart` object. +{% include graphql/cart-object.md %} -{% include graphql/cart-object.md %} \ No newline at end of file +[Cart query output]({{page.baseurl}}/graphql/reference/quote.html#cart-output) provides more information about the `Cart` object. \ No newline at end of file diff --git a/guides/v2.3/graphql/reference/quote-set-shipping-address.md b/guides/v2.3/graphql/reference/quote-set-shipping-address.md index c277d0971e0..83b6bd646ea 100644 --- a/guides/v2.3/graphql/reference/quote-set-shipping-address.md +++ b/guides/v2.3/graphql/reference/quote-set-shipping-address.md @@ -110,8 +110,10 @@ The `SetShippingAddressOnCartOutput` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` | Cart! | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. -### Cart object +### Cart object {#CartObject} {% include graphql/cart-object.md %} + +[Cart query output]({{page.baseurl}}/graphql/reference/quote.html#cart-output) provides more information about the `Cart` object. diff --git a/guides/v2.3/graphql/reference/quote-shipping-method.md b/guides/v2.3/graphql/reference/quote-shipping-method.md index 40f4a85820c..bd79a4ec31b 100644 --- a/guides/v2.3/graphql/reference/quote-shipping-method.md +++ b/guides/v2.3/graphql/reference/quote-shipping-method.md @@ -103,12 +103,14 @@ Attribute | Data Type | Description ## Output attributes -The `ShippingMethodInput` object contains the `Cart` object. +The `ShippingMethodOutput` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` | Cart! | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. -### Cart object +### Cart object {#CartObject} {% include graphql/cart-object.md %} + +[Cart query output]({{page.baseurl}}/graphql/reference/quote.html#cart-output) provides more information about the `Cart` object. diff --git a/guides/v2.3/graphql/reference/quote-update-cart-items.md b/guides/v2.3/graphql/reference/quote-update-cart-items.md index d4d08f6e195..3615d9f5956 100644 --- a/guides/v2.3/graphql/reference/quote-update-cart-items.md +++ b/guides/v2.3/graphql/reference/quote-update-cart-items.md @@ -10,7 +10,7 @@ Setting the quantity to 0 removes an item from the cart. ## Syntax -`mutation; {updateCartItems(input: UpdateCartItemsInput): UpdateCartItemsOutput}` +`mutation: {updateCartItems(input: UpdateCartItemsInput): {UpdateCartItemsOutput}}` ## Example usage @@ -112,8 +112,10 @@ The `UpdateCartItemsOutput` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` | Cart! | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. -### Cart object +### Cart object {#CartObject} {% include graphql/cart-object.md %} + +[Cart query output]({{page.baseurl}}/graphql/reference/quote.html#cart-output) provides more information about the `Cart` object. \ No newline at end of file diff --git a/guides/v2.3/graphql/reference/quote.md b/guides/v2.3/graphql/reference/quote.md index 90d2154b124..f5fb14beb64 100644 --- a/guides/v2.3/graphql/reference/quote.md +++ b/guides/v2.3/graphql/reference/quote.md @@ -9,7 +9,8 @@ A Quote represents the contents of a customer's shopping cart. It is responsible * Determining estimated shipping costs * Calculating subtotals, computing additional costs, applying coupons, and determining the payment method -## Query +## cart Query {#cart} + Use the `cart` query to retrieve information about a particular cart. ### Syntax @@ -406,7 +407,7 @@ Attribute | Data Type | Description --- | --- | --- `cart_id` | String | A 32-character string that is created when you [create a cart]({{page.baseurl}}/graphql/reference/quote-create-cart.html) -### Output attributes +### Output attributes {#cart-output} The top-level `Cart` object is listed first. All child objects are listed in alphabetical order. From 07e49188b4dd5971ffc4744301fce303b2d07e27 Mon Sep 17 00:00:00 2001 From: Kevin Harper Date: Tue, 14 May 2019 15:46:47 -0500 Subject: [PATCH 5/6] Apply suggestions from code review Co-Authored-By: Erik Marr <45772211+erikmarr@users.noreply.github.com> --- guides/v2.3/graphql/reference/quote-add-simple-products.md | 2 +- guides/v2.3/graphql/reference/quote-payment-method.md | 4 ++-- guides/v2.3/graphql/reference/quote-set-guest-email.md | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/guides/v2.3/graphql/reference/quote-add-simple-products.md b/guides/v2.3/graphql/reference/quote-add-simple-products.md index 6ea57fb0b56..632f5299d84 100644 --- a/guides/v2.3/graphql/reference/quote-add-simple-products.md +++ b/guides/v2.3/graphql/reference/quote-add-simple-products.md @@ -76,7 +76,7 @@ mutation { ### Add a simple product with customizable options to a cart -If a product has a customizable option, the option's value can be specified in the add to cart request. +If a product has a customizable option, you can specify the option's value in the `addSimpleProductsToCart` request. **Request** diff --git a/guides/v2.3/graphql/reference/quote-payment-method.md b/guides/v2.3/graphql/reference/quote-payment-method.md index 71a2aded6ab..53f6059be50 100644 --- a/guides/v2.3/graphql/reference/quote-payment-method.md +++ b/guides/v2.3/graphql/reference/quote-payment-method.md @@ -13,7 +13,7 @@ Check / Money order | `checkmo` No Payment Information Required | `free` Purchase Order | `purchaseorder` -Apply the `setPaymentMethodOnCart` mutation after setting the shipping address and shipping method, and after applying any discounts to the cart. +Apply the `setPaymentMethodOnCart` mutation after setting the shipping address, shipping method, and after applying any discounts to the cart. ## Syntax @@ -94,4 +94,4 @@ Attribute | Data Type | Description {% include graphql/cart-object.md %} -[Cart query output]({{page.baseurl}}/graphql/reference/quote.html#cart-output) provides more information about the `Cart` object. \ No newline at end of file +[Cart query output]({{page.baseurl}}/graphql/reference/quote.html#cart-output) provides more information about the `Cart` object. diff --git a/guides/v2.3/graphql/reference/quote-set-guest-email.md b/guides/v2.3/graphql/reference/quote-set-guest-email.md index 0a710a2bd3a..c49bcffcbe6 100644 --- a/guides/v2.3/graphql/reference/quote-set-guest-email.md +++ b/guides/v2.3/graphql/reference/quote-set-guest-email.md @@ -5,7 +5,7 @@ title: setGuestEmailOnCart mutation For guest customers, you must assign an email to the cart before you place the order. -A logged-in customer specifies an email addresses when they create an account. Therefore, you can place the order without explicitly setting the email. +A logged-in customer specifies an email address when they create an account. Therefore, you can place the order without explicitly setting the email. ## Syntax @@ -65,4 +65,4 @@ Attribute | Data Type | Description {% include graphql/cart-object.md %} -[Cart query output]({{page.baseurl}}/graphql/reference/quote.html#cart-output) provides more information about the `Cart` object. \ No newline at end of file +[Cart query output]({{page.baseurl}}/graphql/reference/quote.html#cart-output) provides more information about the `Cart` object. From 6270077ae635399037e7ab98b075e244c8cd868b Mon Sep 17 00:00:00 2001 From: Kevin Harper Date: Tue, 14 May 2019 16:24:57 -0500 Subject: [PATCH 6/6] incorporate review comments --- .../v2.3/graphql/reference/quote-add-simple-products.md | 2 +- .../v2.3/graphql/reference/quote-add-virtual-products.md | 6 ++++-- guides/v2.3/graphql/reference/quote-apply-coupon.md | 2 +- guides/v2.3/graphql/reference/quote-payment-method.md | 2 +- guides/v2.3/graphql/reference/quote-remove-coupon.md | 2 +- guides/v2.3/graphql/reference/quote-remove-item.md | 2 +- .../v2.3/graphql/reference/quote-set-billing-address.md | 2 +- guides/v2.3/graphql/reference/quote-set-guest-email.md | 2 +- .../v2.3/graphql/reference/quote-set-shipping-address.md | 4 ++-- guides/v2.3/graphql/reference/quote-shipping-method.md | 4 ++-- guides/v2.3/graphql/reference/quote-update-cart-items.md | 8 ++++---- 11 files changed, 19 insertions(+), 17 deletions(-) diff --git a/guides/v2.3/graphql/reference/quote-add-simple-products.md b/guides/v2.3/graphql/reference/quote-add-simple-products.md index 6ea57fb0b56..90d763c3021 100644 --- a/guides/v2.3/graphql/reference/quote-add-simple-products.md +++ b/guides/v2.3/graphql/reference/quote-add-simple-products.md @@ -186,7 +186,7 @@ The `AddSimpleProductsToCartOutput` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart ### Cart object {#CartObject} diff --git a/guides/v2.3/graphql/reference/quote-add-virtual-products.md b/guides/v2.3/graphql/reference/quote-add-virtual-products.md index c0c18dd2c20..9bbbeeba0df 100644 --- a/guides/v2.3/graphql/reference/quote-add-virtual-products.md +++ b/guides/v2.3/graphql/reference/quote-add-virtual-products.md @@ -110,8 +110,10 @@ The `CustomizableOptionInput` object must contain the following attributes: The `VirtualProductCartItemInput` object must contain the following attributes: +Attribute | Data Type | Description +--- | --- | --- `customizable_options` |[[CustomizableOptionInput]](#CustomizableOptionInputVirtual) | An array that defines customizable options for the product -`data` | [CartItemInput!](#CartItemInputVirtual) | An object containing the `sku` and `quantity` of the product. +`data` | [CartItemInput!](#CartItemInputVirtual) | An object containing the `sku` and `quantity` of the product ## Output attributes @@ -119,7 +121,7 @@ The `AddVirtualProductsToCartOutput` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart ### Cart object {#CartObject} diff --git a/guides/v2.3/graphql/reference/quote-apply-coupon.md b/guides/v2.3/graphql/reference/quote-apply-coupon.md index f1ca07eadc7..57f93510bb3 100644 --- a/guides/v2.3/graphql/reference/quote-apply-coupon.md +++ b/guides/v2.3/graphql/reference/quote-apply-coupon.md @@ -106,7 +106,7 @@ The `ApplyCouponToCartOutput` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart ### Cart object {#CartObject} diff --git a/guides/v2.3/graphql/reference/quote-payment-method.md b/guides/v2.3/graphql/reference/quote-payment-method.md index 71a2aded6ab..b149876961e 100644 --- a/guides/v2.3/graphql/reference/quote-payment-method.md +++ b/guides/v2.3/graphql/reference/quote-payment-method.md @@ -88,7 +88,7 @@ The `SetPaymentMethodOnCartOutput` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart ### Cart object {#CartObject} diff --git a/guides/v2.3/graphql/reference/quote-remove-coupon.md b/guides/v2.3/graphql/reference/quote-remove-coupon.md index 4c47e993d91..5875be5b2f2 100644 --- a/guides/v2.3/graphql/reference/quote-remove-coupon.md +++ b/guides/v2.3/graphql/reference/quote-remove-coupon.md @@ -94,7 +94,7 @@ The `removeCouponFromCart` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart ### Cart object {#CartObject} diff --git a/guides/v2.3/graphql/reference/quote-remove-item.md b/guides/v2.3/graphql/reference/quote-remove-item.md index c92fea9f047..df3a25fb384 100644 --- a/guides/v2.3/graphql/reference/quote-remove-item.md +++ b/guides/v2.3/graphql/reference/quote-remove-item.md @@ -86,7 +86,7 @@ The `RemoveItemFromCartOutput` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart ### Cart object {#CartObject} diff --git a/guides/v2.3/graphql/reference/quote-set-billing-address.md b/guides/v2.3/graphql/reference/quote-set-billing-address.md index 43a62e08046..c92893c8ff6 100644 --- a/guides/v2.3/graphql/reference/quote-set-billing-address.md +++ b/guides/v2.3/graphql/reference/quote-set-billing-address.md @@ -106,7 +106,7 @@ The `SetBillingAddressOnCartOutput` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart ### Cart object {#CartObject} diff --git a/guides/v2.3/graphql/reference/quote-set-guest-email.md b/guides/v2.3/graphql/reference/quote-set-guest-email.md index 0a710a2bd3a..5f65d038d4b 100644 --- a/guides/v2.3/graphql/reference/quote-set-guest-email.md +++ b/guides/v2.3/graphql/reference/quote-set-guest-email.md @@ -59,7 +59,7 @@ The `SetGuestEmailOnCartOutput` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart ### Cart object {#CartObject} diff --git a/guides/v2.3/graphql/reference/quote-set-shipping-address.md b/guides/v2.3/graphql/reference/quote-set-shipping-address.md index 83b6bd646ea..aa46f4801f3 100644 --- a/guides/v2.3/graphql/reference/quote-set-shipping-address.md +++ b/guides/v2.3/graphql/reference/quote-set-shipping-address.md @@ -3,7 +3,7 @@ group: graphql title: setShippingAddressesOnCart mutation --- -The `setShippingAddressesOnCart` mutation sets one or more shipping addresses on a specific cart. The shipping address does not need to be specified in the following circumstances +The `setShippingAddressesOnCart` mutation sets one or more shipping addresses on a specific cart. The shipping address does not need to be specified in the following circumstances: * The cart contains only virtual items * When you defined the billing address, you set the `use_for_shipping` attribute to `true`. Magento assigns the same address as the shipping address. @@ -110,7 +110,7 @@ The `SetShippingAddressOnCartOutput` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart ### Cart object {#CartObject} diff --git a/guides/v2.3/graphql/reference/quote-shipping-method.md b/guides/v2.3/graphql/reference/quote-shipping-method.md index bd79a4ec31b..df48a4f3b0a 100644 --- a/guides/v2.3/graphql/reference/quote-shipping-method.md +++ b/guides/v2.3/graphql/reference/quote-shipping-method.md @@ -92,7 +92,7 @@ The top-level `setShippingMethodsOnCartInput` object is listed first. All child Attribute | Data Type | Description --- | --- | --- `cart_id` | String! | The unique ID that identifies the customer's cart -`shipping_methods` | [ShippingMethodInput!](#ShippingMethodInput) | The billing address for a specific cart +`shipping_methods` | [ShippingMethodInput!](#ShippingMethodInput) | The shipping address for a specific cart ### ShippingMethodInput object {#ShippingMethodInput} @@ -107,7 +107,7 @@ The `ShippingMethodOutput` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart ### Cart object {#CartObject} diff --git a/guides/v2.3/graphql/reference/quote-update-cart-items.md b/guides/v2.3/graphql/reference/quote-update-cart-items.md index 3615d9f5956..f02631ba85c 100644 --- a/guides/v2.3/graphql/reference/quote-update-cart-items.md +++ b/guides/v2.3/graphql/reference/quote-update-cart-items.md @@ -6,7 +6,7 @@ title: updateCartItems mutation 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. {:.bs-callout .bs-callout-info} -Setting the quantity to 0 removes an item from the cart. +Setting the quantity to `0` removes an item from the cart. ## Syntax @@ -14,7 +14,7 @@ Setting the quantity to 0 removes an item from the cart. ## Example usage -The following example changes the quantity of cart item 13 to 3. +The following example changes the quantity of cart item `13` to `3`. **Request** @@ -104,7 +104,7 @@ The `CartItemUpdateInput` object must 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 -`quantity` | Float! | The new quantity of the item. A value of 0 removes the item from the cart. +`quantity` | Float! | The new quantity of the item. A value of `0` removes the item from the cart ## Output attributes @@ -112,7 +112,7 @@ The `UpdateCartItemsOutput` object contains the `Cart` object. Attribute | Data Type | Description --- | --- | --- -`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart. +`cart` |[ Cart!](#CartObject) | Describes the contents of the specified shopping cart ### Cart object {#CartObject}