commerce: [BC] Customcheckout error

I have just cloned the project and set my .env with BC then enabled customCheckout which display an error when clicking on checkout. See the picture bellow

TypeError: Cannot read properties of undefined (reading 'fetcher')

Capture d’écran 2021-10-17 à 21 27 16

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 10
  • Comments: 20 (1 by maintainers)

Most upvoted comments

If you try the fix here https://github.com/vercel/commerce/issues/533#issuecomment-981149223 you only just get other errors further down the line. E.g. if you click into Payment Method, you get:

../packages/commerce/dist/utils/use-hook.js (24:0) @ useMutationHook

  22 | export function useMutationHook(hook) {
  23 |     const fetcher = useFetcher();
> 24 |     return hook.useHook({

You also get the same error for Shipping Method.

Getting the custom checkout to actually work therefore just feels like endless whack-a-mole.

I wasn’t able to resolve this, we abandoned Vercel Commerce and went down a different route.

@Florian-crg I managed to get mine working but, you have to add the useCheckout hook to your provider.ts in the BC folder. Check the comment i left in the code below.

export const swellProvider: Provider & { swell: any } = {
  locale: 'en-us',
  cartCookie: SWELL_CHECKOUT_ID_COOKIE,
  swell,
  fetcher,
  cart: { useCart, useAddItem, useUpdateItem, useRemoveItem },
  customer: { useCustomer },
  products: { useSearch },
  checkout: { // Added this object and hook. You will have to fill in the logic for your provider's useCheckout hook.
    useCheckout,
  },

  auth: { useLogin, useLogout, useSignup },
}

Why this issue has not been solved or have no idea to solve yet.

I think custom checkout only works with OrderCloud 😞