Skip to content

Commit

Permalink
Pass customer ID when requesting checkout URL (bigcommerce#943)
Browse files Browse the repository at this point in the history
  • Loading branch information
bookernath authored May 23, 2024
1 parent 19a3d14 commit 8090f8c
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { redirect } from 'next/navigation';
import { z } from 'zod';

import { getSessionCustomerId } from '~/auth';
import { client } from '~/client';
import { graphql } from '~/client/graphql';

Expand All @@ -20,11 +21,13 @@ const CheckoutRedirectMutation = graphql(`

export const redirectToCheckout = async (formData: FormData) => {
const cartId = z.string().parse(formData.get('cartId'));
const customerId = await getSessionCustomerId();

const { data } = await client.fetch({
document: CheckoutRedirectMutation,
variables: { cartId },
fetchOptions: { cache: 'no-store' },
customerId,
});

const url = data.cart.createCartRedirectUrls.redirectUrls?.redirectedCheckoutUrl;
Expand Down

0 comments on commit 8090f8c

Please sign in to comment.