Skip to main content

ShoppingCart type

type ShoppingCart {
  id: ID!
  sessionId: String!
  items: [CartItem!]!
  totalCo2Equivalent: Float!
  totalMkiScore: Float
  shippingImpact: Float
  equivalency: Equivalency
  perItemBreakdown: [CartItemImpact!]!
  updatedAt: DateTime!
}

type CartItem {
  productId: ID!
  product: Product!
  quantity: Int!
}

type CartItemImpact {
  productId: ID!
  productName: String!
  quantity: Int!
  co2Equivalent: Float!
  percentage: Float!
}

input CartInput {
  sessionId: String!
  items: [CartItemInput!]!
  shippingMethod: TransportMethod
  shippingAddress: AddressInput
}

input CartItemInput {
  productId: ID!
  quantity: Int!
}

input AddressInput {
  country: String!
  postalCode: String
}

Fields

FieldTypeDescription
idID!Cart identifier
sessionIdString!E-commerce session ID
items[CartItem!]!Items in the cart
totalCo2EquivalentFloat!Total cart carbon footprint
totalMkiScoreFloatTotal MKI score
shippingImpactFloatShipping-related emissions
equivalencyEquivalencyHuman-readable total impact
perItemBreakdown[CartItemImpact!]!Impact per line item

Example mutation

mutation {
  calculateCartImpact(input: {
    sessionId: "session_abc"
    items: [
      { productId: "prod_abc123", quantity: 2 },
      { productId: "prod_def456", quantity: 1 }
    ]
    shippingMethod: STANDARD
    shippingAddress: { country: "NL", postalCode: "1012AB" }
  }) {
    totalCo2Equivalent
    totalMkiScore
    shippingImpact
    perItemBreakdown {
      productName
      quantity
      co2Equivalent
      percentage
    }
    equivalency {
      description
      value
    }
  }
}

Shopify integration

For Shopify stores, use the session ID from the Shopify cart token:
mutation {
  calculateCartImpact(input: {
    sessionId: "shopify_cart_abc123"
    items: [
      { productId: "shopify_variant_123", quantity: 1 }
    ]
    shippingMethod: STANDARD
    shippingAddress: { country: "NL" }
  }) {
    totalCo2Equivalent
    equivalency { description value }
  }
}
See the Shopify SDK for a drop-in integration.