The following below steps need to create Customer Cart ID For Logged & Guest Customer By Using GraphQL in Magento 2.x / Adobe Commerce 2.x
We are going to create Customer Cart ID for logged Customer as well as Guest Customer
Before Creating Customer Cart ID, need to specify the customer’s authorization token in the headers. Otherwise, Query Error as “Get customer authorization token”
Step [1] – Customer Cart ID for Logged Customer, use below
customerCart
Step [1.1] – Recommendation to use below Customer Cart ID syntax
Here Using Postman
Syntax –
{
customerCart{
id
}
}
Step [1.2] – Put below Request
{
customerCart{
id
}
}
Step [1.3] – Below output response
{
"data": {
"customerCart": {
"id": "s6Wgi4j0H2ULX0YHfD3mhOMHuAL10qLL"
}
}
}
Step [2] – Customer Cart ID for Guest Customer, use below
customerEmptyCart
Step [2.1] – Recommendation to use below Customer Cart ID syntax
Here Using Postman
mutation {
createEmptyCart
}
Step [2.2] – Put below Request
mutation {
createEmptyCart
}
Step [2.3] – Below Output Response
{
{
"data": {
"createEmptyCart": "s6Wgi4j0H2ULX0YHfD3mhOMHuAL10qLL"
}
}