Remove um produto do carrinho ou reduz sua quantidade.
RemoveShoppingCartItemMutationInput!
| Campo | Tipo | Descrição |
|---|---|---|
| hostname | String! | Hostname da loja. |
| productId | ID! | ID global Relay do produto a remover. |
| Campo | Tipo | Descrição |
|---|---|---|
| shoppingCart | ShoppingCart | Carrinho atualizado após remoção. |
mutation RemoveItem($input: RemoveShoppingCartItemMutationInput!) {
removeShoppingCartItem(input: $input) {
shoppingCart {
id
totalPrice
totalQuantity
products {
id
title
quantity
}
}
}
} {
"input": {
"hostname": "minha-loja",
"productId": "UHJvZHVjdDphYmMx"
}
} {
"data": {
"removeShoppingCartItem": {
"shoppingCart": {
"id": "Q2FydDp4eXo=",
"totalPrice": 0,
"totalQuantity": 0,
"products": []
}
}
}
} const response = await fetch('/graphql', {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
query: `mutation($input: RemoveShoppingCartItemInput!) {
removeShoppingCartItem(input: $input) {
shoppingCart { id totalPrice totalQuantity }
}
}`,
variables: { input: { hostname: "minha-loja", productId: "UHJvZHVjdDphYmMx" } }
})
}); curl -X POST https://minha-loja.com/graphql \
-H "Content-Type: application/json" \
-b "authJwtClient=YOUR_SESSION_COOKIE" \
-d '{"query":"mutation { removeShoppingCartItem(input: { hostname: \"minha-loja\", productId: \"UHJvZHVjdDphYmMx\" }) { shoppingCart { id totalPrice } } }"}'