-
Notifications
You must be signed in to change notification settings - Fork 2
docs(example): Next - WooCommerce basic example #361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a new WooCommerce integration example for Next.js, demonstrating headless WordPress setup with e-commerce functionality. The example includes template hierarchy implementation, authentication, cart management, and checkout functionality.
Key Changes:
- Added complete WooCommerce example with Next.js Pages Router integration
- Implemented WordPress template hierarchy system for dynamic routing
- Created authentication and cart management providers with session handling
Reviewed changes
Copilot reviewed 106 out of 119 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/nuxt/template-hierarchy-data-fetching/.wp-env.json | Updated development and test port numbers |
| examples/nuxt/template-hierarchy-data-fetching/example-app/nuxt.config.ts | Updated WordPress URL port to match new wp-env configuration |
| examples/next/woocommerce/package.json | Added package configuration with wp-env scripts and dependencies |
| examples/next/woocommerce/wp-env/setup/.htaccess | Added Apache configuration for CORS and WordPress permalinks |
| examples/next/woocommerce/wp-env/sample_products.csv | Added sample WooCommerce product data for development |
| examples/next/woocommerce/example-app/tsconfig.json | Added TypeScript configuration for the Next.js application |
| examples/next/woocommerce/example-app/src/wp-templates/* | Implemented WordPress template hierarchy templates |
| examples/next/woocommerce/example-app/src/lib/* | Added core utilities for GraphQL, authentication, and routing |
| examples/next/woocommerce/example-app/src/components/* | Created UI components for products, cart, checkout, and layout |
| examples/next/woocommerce/example-app/src/interfaces/* | Defined TypeScript interfaces for type safety |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
examples/next/woocommerce/example-app/src/components/OrderReceived/OrderReceived.tsx
Outdated
Show resolved
Hide resolved
examples/next/woocommerce/example-app/src/components/ui/Field.tsx
Outdated
Show resolved
Hide resolved
examples/next/woocommerce/example-app/src/components/Products/Price.tsx
Outdated
Show resolved
Hide resolved
examples/next/woocommerce/example-app/src/components/Checkout/CheckoutFields.tsx
Outdated
Show resolved
Hide resolved
examples/next/woocommerce/example-app/src/components/Products/SingleProduct.tsx
Outdated
Show resolved
Hide resolved
|
Thanks @alexwpengine, thats an impressively comprehensive example. I've tested locally and everything seems to work nicely, except the suggestions I've placed above. |
…ived/OrderReceived.tsx Co-authored-by: Copilot <[email protected]>
…SingleProduct.tsx Co-authored-by: Huseyn Aghayev <[email protected]>
Ready. All points are resolved. Did also some improvements. Removed the screenshots, not sure if its needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 107 out of 119 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
examples/next/woocommerce/example-app/src/lib/templates/templates.js
Outdated
Show resolved
Hide resolved
examples/next/woocommerce/example-app/src/components/Account/Tabs/Orders.tsx
Outdated
Show resolved
Hide resolved
examples/next/woocommerce/example-app/src/components/Cart/MiniCart.tsx
Outdated
Show resolved
Hide resolved
examples/next/woocommerce/example-app/src/wp-templates/page-order-received.js
Outdated
Show resolved
Hide resolved
examples/next/woocommerce/example-app/src/components/Products/Grouped.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 107 out of 119 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import { GetCartDocument } from "./graphQL/userGraphQL"; | ||
| import { GraphQLClient } from "graphql-request"; | ||
| import { setContext } from "@apollo/client/link/context"; | ||
| const baseUrl = process.env.NEXT_PUBLIC_WORDPRESS_URL || "http://localhost:8890"; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
|
||
|
|
||
| return ( | ||
| <button | ||
| key={option} | ||
| onClick={() => onAttributeSelect(attr.name, option)} | ||
| className={`px-4 py-2 border rounded-lg text-sm font-medium transition-all ${ | ||
| isSelected | ||
| ? "bg-blue-600 text-white border-blue-600" | ||
|
|
||
| : "bg-white hover:bg-gray-50 border-gray-300 text-gray-500 opacity-60" | ||
| }`} | ||
| > | ||
| {option} | ||
|
|
Copilot
AI
Dec 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All options receive the same styling (line 95) regardless of whether they're available based on the availableOptions filter. Non-available options should have distinct visual styling (e.g., different opacity, disabled cursor) to indicate they cannot be selected with the current attribute combination.
| return ( | |
| <button | |
| key={option} | |
| onClick={() => onAttributeSelect(attr.name, option)} | |
| className={`px-4 py-2 border rounded-lg text-sm font-medium transition-all ${ | |
| isSelected | |
| ? "bg-blue-600 text-white border-blue-600" | |
| : "bg-white hover:bg-gray-50 border-gray-300 text-gray-500 opacity-60" | |
| }`} | |
| > | |
| {option} | |
| const isAvailable = availableOptions.includes(option); | |
| return ( | |
| <button | |
| key={option} | |
| onClick={() => isAvailable && onAttributeSelect(attr.name, option)} | |
| className={`px-4 py-2 border rounded-lg text-sm font-medium transition-all ${ | |
| isSelected | |
| ? "bg-blue-600 text-white border-blue-600" | |
| : isAvailable | |
| ? "bg-white hover:bg-gray-50 border-gray-300 text-gray-500" | |
| : "bg-white border-gray-300 text-gray-400 opacity-50 cursor-not-allowed" | |
| }`} | |
| disabled={!isAvailable} | |
| aria-disabled={!isAvailable} | |
| > | |
| {option} |
examples/next/woocommerce/example-app/src/components/Products/Variations.tsx
Outdated
Show resolved
Hide resolved
| value={formData.shipping[field.id.replace("shipping_", "").replace(/_([a-z])/g, (_, l) => l.toUpperCase()) as keyof typeof formData.shipping] || ""} | ||
| onChange={(value) => handleFieldChange(field.id, value)} | ||
| placeholder={field.label} | ||
| error={errors[field.id]} |
Copilot
AI
Dec 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error prop is passed to UserField component, but the UserField interface in Field.tsx (lines 3-13) doesn't include an error prop, which will cause a type mismatch.
…Variations.tsx Co-authored-by: Copilot <[email protected]>




Description
WooCommerce basic example - add/remove/update item in cart, checkout, my account, coupons, basic validations.
Plugins Required
Pages
Core functionality
Related Issue
Dependant PRs
Type of Change
How Has This Been Tested?
Screenshots
Checklist