diff --git a/.changeset/thin-scissors-ring.md b/.changeset/thin-scissors-ring.md new file mode 100644 index 000000000..ee381ba66 --- /dev/null +++ b/.changeset/thin-scissors-ring.md @@ -0,0 +1,6 @@ +--- +"@bigcommerce/catalyst-client": minor +"@bigcommerce/catalyst-core": patch +--- + +removes fetch cart redirect from client and fetch it with gql diff --git a/core/app/[locale]/(default)/cart/_components/checkout-button.tsx b/core/app/[locale]/(default)/cart/_components/checkout-button.tsx index 7db9b54b8..4c430a175 100644 --- a/core/app/[locale]/(default)/cart/_components/checkout-button.tsx +++ b/core/app/[locale]/(default)/cart/_components/checkout-button.tsx @@ -1,8 +1,27 @@ -import { getCheckoutUrl } from '~/client/management/get-checkout-url'; +import { client } from '~/client'; +import { graphql } from '~/client/graphql'; import { Button } from '~/components/ui/button'; +export const CheckoutButtonMutation = graphql(` + mutation CheckoutButtonMutation($cartId: String!) { + cart { + createCartRedirectUrls(input: { cartEntityId: $cartId }) { + redirectUrls { + redirectedCheckoutUrl + } + } + } + } +`); + export const CheckoutButton = async ({ cartId, label }: { cartId: string; label: string }) => { - const checkoutUrl = await getCheckoutUrl(cartId); + const { data } = await client.fetch({ + document: CheckoutButtonMutation, + variables: { cartId }, + fetchOptions: { cache: 'no-store' }, + }); + + const checkoutUrl = data.cart.createCartRedirectUrls.redirectUrls?.redirectedCheckoutUrl; return (