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

Redirect to checkout (locale based) #1393

Open
serjdrn opened this issue Oct 23, 2024 · 1 comment
Open

Redirect to checkout (locale based) #1393

serjdrn opened this issue Oct 23, 2024 · 1 comment

Comments

@serjdrn
Copy link

serjdrn commented Oct 23, 2024

No option to ammend a locale parameter (e.g. from next-intl) to redirect to the checkout in the correct languange.

@schmitt-christopher
Copy link

schmitt-christopher commented Mar 27, 2025

Hey,
you just need to adjust the cart query:

export const getCartQuery = (language?: string) => /* GraphQL */ `
  query getCart($cartId: ID!) @inContext(language: ${(language ?? 'DE').toUpperCase()}) {
    cart(id: $cartId) {
      ...cart
    }
  }
  ${cartFragment}
`;


export async function getCart(cartId: string): Promise<Cart | undefined> {
  const language = await getLocale();
  const res = await shopifyFetch<ShopifyCartOperation>({
    query: getCartQuery(language),
    variables: { cartId },
    tags: [TAGS.cart],
    cache: 'no-store'
  });

  // Old carts becomes `null` when you checkout.
  if (!res.body.data.cart) {
    return undefined;
  }

  return reshapeCart(res.body.data.cart);
}

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

2 participants