commerce icon indicating copy to clipboard operation
commerce copied to clipboard

[BC] Customcheckout error

Open Florian-crg opened this issue 2 years ago • 9 comments

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

Florian-crg avatar Oct 17 '21 19:10 Florian-crg

I am getting this error as well but using Swell provider

ReevMich avatar Nov 28 '21 17:11 ReevMich

@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 },
}

ReevMich avatar Nov 28 '21 20:11 ReevMich

@ReevMich should do the same thing in the Shopify folder ? having the same issue

GodwinEbikwo avatar Dec 20 '21 14:12 GodwinEbikwo

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.

brightonmike avatar Feb 17 '22 10:02 brightonmike

Hi @brightonmik I have same error , were you able to solve the error ?

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

  22 | export function useMutationHook(hook) {
  23 |     const fetcher = useFetcher();
> 24 |     return hook.useHook({
  25 |         fetch: useCallback(({ input  } = {})=>{
  26 |             return hook.fetcher({
  27 |                 input,

devlamine avatar Apr 19 '22 00:04 devlamine

+1

guibovo avatar Aug 19 '22 11:08 guibovo

@ReevMich hay did u manage to implement a custom checkout? If so, can you please put some snippets of your useCheckout hook

omerfe avatar Aug 23 '22 12:08 omerfe

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

brightonmike avatar Aug 23 '22 14:08 brightonmike

up! I'm getting the same error trying to proceed checkout with shopify from the cart drawer

mrth2 avatar Sep 16 '22 15:09 mrth2

I think custom checkout only works with OrderCloud 😞

valentin-harrang avatar Nov 06 '22 23:11 valentin-harrang

Having the same issues with Saleor. Did anyone fix this issue or finally implement their own custom checkout?

adityanagar10 avatar Dec 05 '22 15:12 adityanagar10

Same error using Shopify commerce

allexxis avatar Feb 06 '23 01:02 allexxis

same issue with bigcommerce

David05500 avatar Feb 06 '23 23:02 David05500

Looks like all the hooks (useCheckout, useSubmitCheckout) for the checkout functionality are empty. Would anyone know if its something that is coming very soon, or something that we have to roll out ourselves?

David05500 avatar Feb 07 '23 09:02 David05500

i got same error and unable to solve it. If anyone has resolved so can you please tell me. And i am using Next js storefront with vendure

Imtiyaz94 avatar Feb 23 '23 07:02 Imtiyaz94

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

Imtiyaz94 avatar Feb 23 '23 08:02 Imtiyaz94

This would be amazing if this can be addressed. This is a really wonderful project and works great otherwise, its a shame this is holding it back

marcabisamra avatar Mar 11 '23 15:03 marcabisamra

same issue with shopify

cahyawibawa avatar Mar 30 '23 08:03 cahyawibawa

Same error getting with me

jitupatel76877 avatar Apr 13 '23 10:04 jitupatel76877

Hey there! Thank you for opening this issue. We have decided to take Next.js Commerce in a new direction and will be closing out current PRs and issues due to this change. Please see this PR for more details: https://github.com/vercel/commerce/pull/966

leerob avatar Apr 18 '23 02:04 leerob