Awesome Open Source
Awesome Open Source

Language grade: JavaScript Codacy Badge CodeFactor Quality Gate Status

Screenshot 1

Next.js Ecommerce site with WooCommerce backend

Live URL: https://next-woocommerce.dfweb.no

Table Of Contents (TOC)

Installation

  1. Install and activate the following required plugins, in your WordPress plugin directory:

Optional plugin:

The current release has been tested and is confirmed working with the following versions:

  • WordPress version 6.0.1
  • WooCommerce version 6.4.1
  • WP GraphQL version 1.5.0
  • WooGraphQL version 0.6.2
  1. For debugging and testing, install either:

    https://addons.mozilla.org/en-US/firefox/addon/apollo-developer-tools/ (Firefox)

    https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm (Chrome)

  2. Make sure WooCommerce has some products already or import some sample products

    The WooCommerce sample products CSV file is available at wp-content/plugins/woocommerce/sample-data/sample_products.csv or Sample products

    Import the products at WP Dashboard > Tools > Import > WooCommerce products(CSV)

  3. Clone or fork the repo and modify .env.example and rename it to .env

    Then set the environment variables accordingly in Vercel or your preferred hosting solution.

    See https://vercel.com/docs/environment-variables

  4. Modify the values according to your setup

  5. Start the server with npm run dev

  6. Enable COD (Cash On Demand) payment method in WooCommerce

  7. Add a product to the cart

  8. Proceed to checkout (Gå til kasse)

  9. Fill in your details and place the order

Features

  • Next.js version 12.3.0
  • Connect to Woocommerce GraphQL API and list name, price and display image for products
  • Support for simple products and variable products
  • Cart handling and checkout with WooCommerce (Cash On Delivery only for now)
  • Algolia search (requires algolia-woo-indexer)
  • Meets WCAG accessibility standards where possible
  • Placeholder for products without images
  • Apollo Client with GraphQL
  • React Hook Form with form validation and error display
  • Animations with Framer motion, Styled components and Animate.css
  • Loading spinner created with Styled Components
  • Shows page load progress with Nprogress during navigation
  • Fully responsive design
  • Category and product listings
  • Pretty URLs with builtin Nextjs functionality
  • Tailwind 3 for styling
  • JSDoc comments
  • WooCommerce cart session is automatically deleted after 48 hours to prevent GraphQL session expiration errors

Troubleshooting

I am getting a cart undefined error or other GraphQL errors

Check that you are using the 0.6.2 version of the wp-graphql-woocommerce plugin

The products page isn't loading

Check the attributes of the products. Right now the application requires Size and Color.

Issues

Overall the application is working as intended, but it has not been tested extensively in a production environment. More testing and debugging is required before deploying it in a production environment.

With that said, keep the following in mind:

  • Currently only simple products and variable products work without any issues. Other product types are not known to work.
  • Only Cash On Delivery (COD) is currently supported. More payment methods may be added later.

TODO

  • Add total to cart/checkout page
  • Show stock quantity on individual products
  • Copy billing address to shipping address
  • Display product variation name in cart / checkout
  • Hide products not in stock
  • Add better SEO
  • Re-add Next/image when it is working better
Alternatives To Nextjs Woocommerce
Select To Compare


Alternative Project Comparisons
Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Javascript (1,092,374
Reactjs (167,060
Wordpress (29,576
Graphql (15,986
Nextjs (12,370
Tailwindcss (7,014
E Commerce (5,148
Cart (5,070
Apollo (4,472
Styled Components (4,465
Woocommerce (2,677
Cash (1,415
Algolia (864
Framer Motion (453
React Hook Form (189
Animatecss (164
Algolia Search (119
Wpgraphql (43
Woocommerce Api (30
Ecommerce Site (21