Documentation Index
Fetch the complete documentation index at: https://docs.heychocolate.com/llms.txt
Use this file to discover all available pages before exploring further.
calculateCartImpact
Calculate the total environmental impact of a shopping cart in real-time.
mutation {
calculateCartImpact(input: {
sessionId: "session_abc"
items: [
{ productId: "prod_abc123", quantity: 2 },
{ productId: "prod_def456", quantity: 1 },
{ productId: "prod_ghi789", quantity: 5 }
]
shippingMethod: STANDARD
shippingAddress: { country: "NL", postalCode: "1012AB" }
}) {
totalCo2Equivalent
totalMkiScore
shippingImpact
perItemBreakdown {
productId
productName
quantity
co2Equivalent
percentage
}
equivalency {
description
value
icon
}
}
}
Input:
| Field | Type | Required | Description |
|---|
sessionId | String! | Yes | E-commerce session/cart ID |
items | [CartItemInput!]! | Yes | Cart line items |
shippingMethod | TransportMethod | No | Delivery method |
shippingAddress | AddressInput | No | Delivery address |
| Field | Type | Required | Description |
|---|
productId | ID! | Yes | Product identifier |
quantity | Int! | Yes | Quantity |
updateCartItem
Update a single item in the cart and get the recalculated impact.
mutation {
updateCartItem(input: {
sessionId: "session_abc"
productId: "prod_abc123"
quantity: 5
}) {
totalCo2Equivalent
perItemBreakdown {
productId
co2Equivalent
percentage
}
equivalency {
description
value
}
}
}
removeCartItem
Remove an item from the cart.
mutation {
removeCartItem(input: {
sessionId: "session_abc"
productId: "prod_abc123"
}) {
totalCo2Equivalent
perItemBreakdown {
productId
co2Equivalent
}
}
}
E-commerce integration
For Shopify stores, use the cart token as the sessionId:
const cartImpact = await client.calculateCartImpact({
sessionId: window.Shopify.cart.token,
items: cart.items.map(item => ({
productId: item.variant_id.toString(),
quantity: item.quantity,
})),
shippingAddress: { country: shippingCountry },
});
See the Shopify SDK for a complete integration guide.