Re: Storefront API - Customer Cart

Storefront API - Customer Cart

Hmmaen
Visitor
2 0 0

Hi,

We create cart with Storefront APIs cartCreate mutation and attach customer to cart with cartBuyerIdentityUpdate mutation. I know I can query cart with cart id, but can i query cart with customer access token or customer email address?

 

Replies 4 (4)

AlanForsVispero
Tourist
6 1 0

Hi Hmmaen,

Have you been able to create a cart with line items in it? When I do  so, the cart is always returned empty.

Hmmaen
Visitor
2 0 0

Yes, with createCart-mutation like:

mutation createCart($cartInput: CartInput) {
  cartCreate(input: $cartInput) {
    cart {
      id
      createdAt
      updatedAt
      lines(first:10) {
        edges {
          node {
            id
            merchandise {
              ... on ProductVariant {
                id 
                sku
              }
            }
          }
        }
      }
    }
  }
}

 

cartInput where merchandiseId value is variants storefrontid:

{
  "cartInput": {
    "lines": [
      {
        "quantity": 6,
        "merchandiseId": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8zOTgwNTMzMjY1MjIwOA=="
      }
    ]
  }
}

 

AlanForsVispero
Tourist
6 1 0

That looks remarkably similar to the mutation I'm using, yet I always end up with an empty cart.

Thanks for responding.

_chath_s_
Tourist
5 0 6

Hi were you able to figure this out?