mergeCarts
mergeCarts is a Magento 2 GraphQL mutation in the Quote module. phpcs:ignore Magento2.GraphQL.ValidArgumentName. It returns Cart! and requires an Authorization header (Bearer customer token).
Last verified: against Magento 2.4.9.
Returns
Cart!
Resolver class
Magento\QuoteGraphQl\Model\Resolver\MergeCarts
Arguments
The guest's cart ID before they login.
The cart ID after the guest logs in.
Example request
Auto-generated from the SDL — paste-ready against your store's /graphql endpoint. Replace the host, store code, and any required values before running.
Headers
Query
mutation ($source_cart_id: String!) {
mergeCarts(source_cart_id: $source_cart_id) {
gift_message {
to
from
message
}
id
items {
not_available_message
id
uid
quantity
is_available
prices {
price { ... }
price_including_tax { ... }
row_total { ... }
row_total_including_tax { ... }
discounts { ... }
total_item_discount { ... }
original_item_price { ... }
original_row_total { ... }
catalog_discount { ... }
row_catalog_discount { ... }
fixed_product_taxes { ... }
}
product {
id
uid
name
sku
description { ... }
short_description { ... }
special_price
special_from_date
special_to_date
attribute_set_id
meta_title
meta_keyword
meta_description
image { ... }
small_image { ... }
thumbnail { ... }
new_from_date
new_to_date
tier_price
options_container
created_at
updated_at
country_of_manufacture
type_id
websites { ... }
product_links { ... }
media_gallery_entries { ... }
price { ... }
price_range { ... }
gift_message_available
manufacturer
categories { ... }
canonical_url
media_gallery { ... }
custom_attributesV2 { ... }
tier_prices { ... }
price_tiers { ... }
only_x_left_in_stock
stock_status
quantity
min_sale_qty
max_sale_qty
url_key
url_suffix
url_path
url_rewrites { ... }
related_products { ... }
upsell_products { ... }
crosssell_products { ... }
rating_summary
review_count
reviews { ... }
swatch_image
}
errors {
code
message
}
}
itemsV2 {
items {
not_available_message
id
uid
quantity
is_available
prices { ... }
product { ... }
errors { ... }
}
page_info {
page_size
current_page
total_pages
}
total_count
}
applied_coupon {
code
}
applied_coupons {
code
}
email
shipping_addresses {
available_shipping_methods {
carrier_code
carrier_title
method_code
method_title
error_message
amount { ... }
base_amount { ... }
price_excl_tax { ... }
price_incl_tax { ... }
available
}
selected_shipping_method {
carrier_code
method_code
carrier_title
method_title
amount { ... }
base_amount { ... }
price_excl_tax { ... }
price_incl_tax { ... }
}
customer_notes
items_weight
cart_items {
cart_item_id
quantity
}
cart_items_v2 {
not_available_message
id
uid
quantity
is_available
prices { ... }
product { ... }
errors { ... }
}
same_as_billing
pickup_location_code
}
billing_address {
customer_notes
}
available_payment_methods {
is_deferred
code
title
}
selected_payment_method {
code
title
purchase_order_number
}
prices {
grand_total {
value
currency
}
grand_total_excluding_tax {
value
currency
}
subtotal_including_tax {
value
currency
}
subtotal_excluding_tax {
value
currency
}
discount {
amount { ... }
label
}
subtotal_with_discount_excluding_tax {
value
currency
}
applied_taxes {
amount { ... }
label
}
discounts {
amount { ... }
applied_to
label
coupon { ... }
}
}
total_quantity
is_virtual
rules {
uid
}
}
}Variables
{
"source_cart_id": ""
}Related in QuoteGraphQl
Other fields shipped by the same module.
addProductsToCart
Add any type of product to the cart.
Quote · returns AddProductsToCartOutput
addSimpleProductsToCart
Add one or more simple products to the specified cart. We recommend using `addProductsToCart` instead.
Quote · returns AddSimpleProductsToCartOutput
addVirtualProductsToCart
Add one or more virtual products to the specified cart. We recommend using `addProductsToCart` instead.
Quote · returns AddVirtualProductsToCartOutput
applyCouponToCart
Apply a pre-defined coupon code to the specified cart.
Quote · returns ApplyCouponToCartOutput
assignCustomerToGuestCart
phpcs:ignore Magento2.GraphQL.ValidArgumentName
Quote · returns Cart!
cart
phpcs:ignore Magento2.GraphQL.ValidArgumentName
Quote · returns Cart
Every Magento dev tool, in one hosted workspace.
Free to sign up. Nothing to install. Drafts, audits, and projects saved across every tool.