vercel / commerce

Next.js Commerce
https://demo.vercel.store
MIT License
11.17k stars 4.1k forks source link

[BC] Customcheckout error #533

Closed Florian-crg closed 1 year ago

Florian-crg commented 2 years ago

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
ReevMich commented 2 years ago

I am getting this error as well but using Swell provider

ReevMich commented 2 years ago

@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 },
}
GodwinEbikwo commented 2 years ago

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

brightonmike commented 2 years ago

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.

devlamine commented 2 years ago

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,
guibovo commented 2 years ago

+1

omerfe commented 2 years ago

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

brightonmike commented 2 years ago

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

mrth2 commented 2 years ago

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

valentin-harrang commented 1 year ago

I think custom checkout only works with OrderCloud 😞

adityanagar10 commented 1 year ago

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

allexxis commented 1 year ago

Same error using Shopify commerce

David05500 commented 1 year ago

same issue with bigcommerce

David05500 commented 1 year ago

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?

Imtiyaz94 commented 1 year ago

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 commented 1 year ago

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

marcabisamra commented 1 year ago

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

cahyawibawa commented 1 year ago

same issue with shopify

jitupatel76877 commented 1 year ago

Same error getting with me

leerob commented 1 year ago

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