chec / commercejs-nextjs-demo-store

Commerce demo store built for the Jamstack. Built with Commerce.js, Next.js, and can be one-click deployed to Netlify. Includes product catalog, customer login, categories, variants, cart, checkout, payments (Stripe) order confirmation, and printable receipts.
https://commercejs-demo-store.netlify.app/
BSD 3-Clause "New" or "Revised" License
1.07k stars 206 forks source link

Order confirmation page and print receipt #17

Closed jaepass closed 4 years ago

jaepass commented 4 years ago

Kapture 2020-05-04 at 20 50 51

ScopeyNZ commented 4 years ago

Hmmn there's a new error now. You might have to try using yarn deploy locally to go through issues as they occur.

jaepass commented 4 years ago

hm yea now the error is not being able to read the properties from the order object. this is odd, wasn't happening til now, will yarn deploy and look locally

jaepass commented 4 years ago

im thinking it has something to do with Next somehow thinking checkout/confirm is ssr and to prepopulate with prop that simply doesn't exist

λ /checkout/confirm 
λ  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
Error occurred prerendering page "/checkout/confirm". Read more: https://err.sh/next.js/prerender-error
ScopeyNZ commented 4 years ago

I wonder what happens if you start that render function with

if (!orderReceipt) {
  return null;
}
jaepass commented 4 years ago

ah so just running yarn build works with no build errors. https://nextjs.org/docs/advanced-features/static-html-export talks about caveats with next export with getInitialProps() pages.

jaepass commented 4 years ago

error is directly pointed to next.js trying to pre-render order/confirm at build time and Next.js opting out of automatic static optimization due to there being getInitialProps(). hm so looks like essentially every page that doesn't have getStaticProps() is automatically ssr. https://github.com/zeit/next.js/issues/9285

ScopeyNZ commented 4 years ago

Does removing next export work?

jaepass commented 4 years ago

sorry for the builds and commits, just trying to isolate some scenarios. trying to manually disable ssr on the order page

jaepass commented 4 years ago

known build error: https://github.com/zeit/next.js/issues/8014

FIXED: