woocommerce
Build e-commerce stores with WooCommerce for WordPress. Use when a user asks to add a shop to WordPress, manage products and orders, customize checkout, integrate payment gateways, or build a WordPress-based online store.
What this skill does
# WooCommerce
## Overview
WooCommerce is the most popular e-commerce platform — powers ~40% of all online stores. It's a free WordPress plugin with extensions for payments, shipping, subscriptions, and multi-currency. Fully customizable with PHP hooks and REST API.
## Instructions
### Step 1: REST API Integration
```typescript
// lib/woo.ts — WooCommerce REST API client
import WooCommerceRestApi from '@woocommerce/woocommerce-rest-api'
const woo = new WooCommerceRestApi({
url: 'https://store.example.com',
consumerKey: process.env.WOO_KEY!,
consumerSecret: process.env.WOO_SECRET!,
version: 'wc/v3',
})
// List products
const { data: products } = await woo.get('products', { per_page: 20, status: 'publish' })
// Create product
await woo.post('products', {
name: 'Premium T-Shirt',
type: 'simple',
regular_price: '29.99',
description: 'High-quality cotton t-shirt',
categories: [{ id: 15 }],
images: [{ src: 'https://example.com/tshirt.jpg' }],
})
// Get orders
const { data: orders } = await woo.get('orders', { status: 'processing' })
// Update order status
await woo.put(`orders/${orderId}`, { status: 'completed' })
```
### Step 2: Custom Hooks (PHP)
```php
// functions.php — WooCommerce customization hooks
// Add custom field to checkout
add_action('woocommerce_after_order_notes', function($checkout) {
woocommerce_form_field('delivery_notes', [
'type' => 'textarea',
'label' => 'Delivery Notes',
'placeholder' => 'Special instructions for delivery',
], $checkout->get_value('delivery_notes'));
});
// Custom discount logic
add_action('woocommerce_cart_calculate_fees', function($cart) {
if ($cart->get_subtotal() > 100) {
$cart->add_fee('Bulk discount', -10); // $10 off orders over $100
}
});
```
### Step 3: Webhooks
```typescript
// api/woo/webhook.ts — Handle WooCommerce events
export async function POST(req: Request) {
const event = req.headers.get('x-wc-webhook-topic')
const data = await req.json()
switch (event) {
case 'order.created':
await notifySlack(`New order #${data.id}: $${data.total} from ${data.billing.email}`)
break
case 'order.completed':
await sendThankYouEmail(data.billing.email, data)
break
}
return new Response('OK')
}
```
## Guidelines
- WooCommerce is free; costs come from hosting and premium extensions.
- Use REST API for headless commerce — build custom frontends with Next.js/React.
- Performance: WooCommerce on shared hosting struggles past ~500 products. Use dedicated hosting or consider Medusa for headless.
- Extensions marketplace has 800+ plugins for payments, shipping, subscriptions, etc.
Related in Web Dev
generating-lwc-components
IncludedLightning Web Components with PICKLES methodology and 165-point scoring. Use this skill when the user creates or edits LWC components, builds wire service patterns, or writes Jest tests for LWC. TRIGGER when: user creates/edits LWC components, touches lwc/**/*.js, .html, .css, .js-meta.xml files, or asks about wire service, SLDS, or Jest LWC tests. DO NOT TRIGGER when: Apex classes (use generating-apex), Aura components, or Visualforce.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Set up queries with useQuery, mutations with useMutation, configure QueryClient caching strategies, implement optimistic updates, and handle infinite scroll with useInfiniteQuery. Use when: setting up data fetching in React projects, migrating from v4 to v5, or fixing object syntax required errors, query callbacks removed issues, cacheTime renamed to gcTime, isPending vs isLoading confusion, keepPreviousData removed problems.
document-processor-api
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
nutrient-document-processing
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Covers useMutationState, simplified optimistic updates, throwOnError, network mode (offline/PWA), and infiniteQueryOptions. Use when setting up data fetching, fixing v4→v5 migration errors (object syntax, gcTime, isPending, keepPreviousData), or debugging SSR/hydration issues with streaming server components.
accelint-nextjs-best-practices
IncludedNext.js performance optimization and best practices. Use when writing Next.js code (App Router or Pages Router); implementing Server Components, Server Actions, or API routes; optimizing RSC serialization, data fetching, or server-side rendering; reviewing Next.js code for performance issues; fixing authentication in Server Actions; or implementing Suspense boundaries, parallel data fetching, or request deduplication.