Skip to content

Conversation

@alexwpengine
Copy link
Contributor

@alexwpengine alexwpengine commented Aug 5, 2025

Description

WooCommerce basic example - add/remove/update item in cart, checkout, my account, coupons, basic validations.

Plugins Required

  1. WooCommerce. No add-ons.
  2. WPGraphQL
  3. WooGraphQL
  4. WPGraphQL Headless Login

Pages

  1. Header navigation - add Cart, My account as icons. List added Cart items under Cart.
  2. Shop Page - list products (with load more button) with add to cart button and simple filter and ordering
  3. Product Page - simple add to cart, display basic info - title, desc, price, quantity, attributes
  4. support simple, grouped, variable products
  5. Product Cat Pages - same as shop page/reusing the product-card component.
  6. Cart - add/remove, order subtotal/total
  7. Checkout - simple validation
  8. Order Received/Thank you page - display order summary.
  9. My account - billing, shipping fields, orders, core user info (password, email).

Core functionality

  1. Add/remove/update from cart and mini-cart and checkout
  2. Off Canvas Cart - quantity update, remove item, clear cart, refresh cart.
  3. Checkout validation
  4. Checkout payment with default payments - CoD, Bank transfer etc. No stripe, paypal etc.
  5. User registration and login (authentication)
  6. Apply coupon codes and discounts.
  7. Template Hierarchy

Related Issue

Dependant PRs

Type of Change

  • ✅ Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactoring (no functional changes)
  • 📄 Example update (no functional changes)
  • 📝 Documentation update
  • 🔍 Performance improvement
  • 🧪 Test update

How Has This Been Tested?

Screenshots

Checklist

  • I have read the CONTRIBUTING document
  • My code follows the project's coding standards
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • Any dependent changes have been highlighted, merged or published

@alexwpengine alexwpengine requested a review from a team as a code owner August 5, 2025 13:56
@changeset-bot
Copy link

changeset-bot bot commented Aug 5, 2025

⚠️ No Changeset found

Latest commit: c85a016

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@alexwpengine alexwpengine self-assigned this Aug 5, 2025
@alexwpengine
Copy link
Contributor Author

PR

@github-project-automation github-project-automation bot moved this to 🆕 Backlog in Headless OSS Aug 5, 2025
@alexwpengine alexwpengine linked an issue Aug 5, 2025 that may be closed by this pull request
@ahuseyn ahuseyn requested a review from Copilot December 3, 2025 10:33
Copy link
Contributor

Copilot AI left a 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.

@ahuseyn
Copy link
Member

ahuseyn commented Dec 3, 2025

Thanks @alexwpengine, thats an impressively comprehensive example. I've tested locally and everything seems to work nicely, except the suggestions I've placed above.
Also you might want to know that the images do not appear when you do the clean install:
Screenshot 2025-12-03 at 11 41 01
Screenshot 2025-12-03 at 11 41 20

@alexwpengine
Copy link
Contributor Author

alexwpengine commented Dec 3, 2025

Thanks @alexwpengine, thats an impressively comprehensive example. I've tested locally and everything seems to work nicely, except the suggestions I've placed above. Also you might want to know that the images do not appear when you do the clean install: Screenshot 2025-12-03 at 11 41 01 Screenshot 2025-12-03 at 11 41 20

Ready. All points are resolved. Did also some improvements. Removed the screenshots, not sure if its needed.

@alexwpengine alexwpengine changed the title [WIP] docs(example): Next - WooCommerce basic example docs(example): Next - WooCommerce basic example Dec 3, 2025
Copy link
Contributor

Copilot AI left a 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.

@alexwpengine alexwpengine requested a review from Copilot December 3, 2025 17:58
Copy link
Contributor

Copilot AI left a 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.

Comment on lines 86 to 100


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}

Copy link

Copilot AI Dec 3, 2025

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.

Suggested change
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}

Copilot uses AI. Check for mistakes.
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]}
Copy link

Copilot AI Dec 3, 2025

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🆕 Backlog

Development

Successfully merging this pull request may close these issues.

Examples: Add WooCommerce into examples

3 participants