Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cart is null in response to "GetCartQuery" #1695

Open
MUlasevich opened this issue Dec 2, 2024 · 4 comments
Open

Cart is null in response to "GetCartQuery" #1695

MUlasevich opened this issue Dec 2, 2024 · 4 comments

Comments

@MUlasevich
Copy link

Describe the bug
After adding item to cart, cart is always null in response to "GetCartQuery", both for guest and logged in user .

Also, every add to cart action results in new cart being created.

To Reproduce
Steps to reproduce the behavior:

  1. Run "npm create @bigcommerce/catalyst@latest", current version is 0.17.0
  2. Manually fill all required variables in .env.local
  3. Start application
  4. Add any item to cart as guest user
  5. Verify success message
  6. Move to /cart route
  7. Verify cart is empty while "cartId" is present in cookies

Expected behavior
User is able to see cart items and proceed to checkout

Screenshots
Screenshot 2024-11-25 at 13 28 59

Additional context
Was able to reproduce the same issue using several different BigCommerce stores

@jtoromats
Copy link

jtoromats commented Dec 9, 2024

@MUlasevich - I was also running into that issue. Did you try using a customer impersonation token instead?

@mhuretski
Copy link

@jtoromats i'm also having the same issue, using customer impersonation token v3/storefront/api-token-customer-impersonation helps to get cart, but login api returns empty customerAccessToken in this case

{
  data: {
    login: {
      customerAccessToken: null,
      customer:
          {
            entityId: 9,
            ......
          }
    }
  }
}

so it's not a solution either.

With v3/storefront/api-token login API works and returns customerAccessToken but query getCart returns null

{
    "data": {
        "site": {
            "cart": null
        }
    }
}

Tried to create new V2/V3 API token with all possible permissions, but the result is the same, is there any solution for this?

@chanceaclark
Copy link
Contributor

Hey @mhuretski, Customer Access Tokens will only be returned when using a Storefront Token instead of a Customer Impersonation token: https://developer.bigcommerce.com/docs/start/authentication/graphql-storefront#customer-access-tokens

You should be able to run pnpm create @bigcommerce/catalyst init which should generate a Storefront Token for you.

@mhuretski
Copy link

Hey @chanceaclark yes, I've created catalyst sales channel with BIGCOMMERCE_STOREFRONT_TOKEN token generated by pnpm create @bigcommerce/catalyst init, but cart is not returned for my existing stores.

I've tested it on a new store, on a brand new bigcommerce store everything works fine.

Issue seems to be connected with existing stores created before new api was released or having some specific store settings preventing new api from working correctly. I've tested it on 2 existing stores and I'm getting cart null there.

Should I create a ticket to customer support on this or perhaps there is some migration guide I missed for existing stores?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants