Magento 2 Create cart by graphql

Magento 2 Create cart by graphql

Magento 2 Create cart by graphql

Setup Altair Graphql for browser.

Create cart for Graphql
Create empty cart like quote id and cart id.

Add to cart with cart id.

mutation {
addSimpleProductsToCart(
input: {
cart_id: “VNUVFksjdu2SPsxgBl2Mdlqrum73PL”
cart_items: [
{

Remove coupon

data: {
quantity: 1
sku: “0768335”
}
}
]
}
) {
cart {
items {
id
product {
name
sku
}
quantity
}
}
}
}
———————-
mutation {
createEmptyCart
}

Assign cart/quote id to cart and get cart details

{
cart(cart_id: “VNUVFksjdu2SPsxgBl2Mdlqrum73PL”) {
email
billing_address {
city
country {
code
label
}
firstname
lastname
postcode
region {
code
label
}
street
telephone
}
shipping_addresses {
firstname
lastname
street
city
region {
code
label
}
country {
code
label
}
telephone
available_shipping_methods {
amount {
currency
value
}
available
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
}
carrier_code
carrier_title
method_code
method_title
}
}
items {
id
product {
name
sku
}
quantity

}
available_payment_methods {
code
title
}
selected_payment_method {
code
title
}
applied_coupons {
code
}
prices {
grand_total {
value
currency
}
}
}
}