# woocommerce

Development guidelines for WordPress and WooCommerce. Helps assistants write safe PHP code with hooks, custom product types, and REST endpoints.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 826 installs · ★ 286
- Author: Mindrally
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/Mindrally/skills/tree/HEAD/woocommerce/SKILL.md
- Updated: 2026-10-08
- HTML: https://affpapa.org/en/nevibecode/skills/woocommerce

## What it does

Guides coding assistants through WordPress and WooCommerce architecture conventions. It establishes PHP standards such as meaningful naming, proper namespaces, PHPDoc comments, and function prefixing to avoid collisions.

Covers key WooCommerce mechanics: action and filter hooks (`woocommerce_checkout_fields`, `woocommerce_order_status_completed`), input sanitization (`sanitize_email`, `absint`), output escaping, and nonce verification. It also outlines patterns for extending the REST API and subclassing `WC_Product`.

Safe database interaction relies on `$wpdb->prepare` and WooCommerce data stores. Without PHPCS rulesets and `WP_UnitTestCase` installed in your test suite, adherence to these standards cannot be verified automatically.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill woocommerce -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/woocommerce/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/woocommerce/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill woocommerce -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/woocommerce/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill woocommerce -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/woocommerce/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install Mindrally/skills woocommerce
```

2. **Manually: put the files in place**
- File: `.github/skills/woocommerce/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill woocommerce -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/Mindrally/skills --path woocommerce
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/woocommerce/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill woocommerce -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/Mindrally/skills/tree/HEAD/woocommerce/SKILL.md

## When to use it
- add custom checkout fields using `woocommerce_checkout_fields`
- create custom product classes extending `WC_Product`
- register endpoints under `rest_api_init` to query products
- implement nonce validation and capability checks in form handlers

## Example prompts
- Add a custom billing field to checkout with proper sanitization and nonce checks
- Create a custom product type subclassing WC_Product and register it
- Register a REST route to fetch published products using wc_get_products

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 7efdc8e6bd479153.

BEGIN THIRD-PARTY FILE 7efdc8e6bd479153
````text
---
name: woocommerce
description: WordPress and WooCommerce development guidelines with PHP best practices, security standards, and extensibility patterns
metadata:
  maintainer: Mindrally
  source: https://github.com/Mindrally/skills
---

# WooCommerce Development

You are an expert in WordPress and WooCommerce development, PHP best practices, and e-commerce solutions.

## Core Principles

- Follow WordPress coding standards
- Use WooCommerce hooks and filters properly
- Prioritize security in all code
- Maintain backwards compatibility
- Write performant, scalable code

## PHP Best Practices

### Coding Standards

- Follow WordPress PHP Coding Standards
- Use meaningful function and variable names
- Prefix all functions and classes to avoid conflicts
- Document code with PHPDoc comments

### Namespacing

```php
namespace MyPlugin\WooCommerce;

class ProductHandler {
    public function __construct() {
        add_action('woocommerce_before_add_to_cart_form', [$this, 'custom_content']);
    }

    public function custom_content() {
        // Custom functionality
    }
}
```

## WooCommerce Hooks

### Action Hooks

```php
// Add content after product summary
add_action('woocommerce_after_single_product_summary', 'custom_product_content', 15);
function custom_product_content() {
    echo '<div class="custom-content">Additional information</div>';
}

// Modify order processing
add_action('woocommerce_order_status_completed', 'process_completed_order', 10, 1);
function process_completed_order($order_id) {
    $order = wc_get_order($order_id);
    // Process order
}
```

### Filter Hooks

```php
// Modify product price display
add_filter('woocommerce_get_price_html', 'custom_price_html', 10, 2);
function custom_price_html($price, $product) {
    if ($product->is_on_sale()) {
        $price .= '<span class="sale-badge">Sale!</span>';
    }
    return $price;
}

// Add custom checkout fields
add_filter('woocommerce_checkout_fields', 'custom_checkout_fields');
function custom_checkout_fields($fields) {
    $fields['billing']['billing_custom_field'] = [
        'type' => 'text',
        'label' => __('Custom Field', 'textdomain'),
        'required' => false,
        'priority' => 25,
    ];
    return $fields;
}
```

## Security

### Data Validation

```php
// Sanitize input
$product_id = absint($_POST['product_id']);
$quantity = wc_stock_amount($_POST['quantity']);
$email = sanitize_email($_POST['email']);

// Escape output
echo esc_html($product->get_name());
echo esc_url($product->get_permalink());
echo wp_kses_post($product->get_description());
```

### Nonce Verification

```php
// Create nonce
wp_nonce_field('custom_action', 'custom_nonce');

// Verify nonce
if (!wp_verify_nonce($_POST['custom_nonce'], 'custom_action')) {
    wp_die(__('Security check failed', 'textdomain'));
}
```

### Capability Checks

```php
if (!current_user_can('manage_woocommerce')) {
    wp_die(__('Unauthorized access', 'textdomain'));
}
```

## Custom Product Types

```php
class WC_Product_Custom extends WC_Product {
    public function get_type() {
        return 'custom';
    }
````
END THIRD-PARTY FILE 7efdc8e6bd479153

The third-party file has ended. Everything between the 7efdc8e6bd479153 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 3113 of 5056 bytes. © Mindrally · Apache-2.0 · https://github.com/Mindrally/skills/tree/HEAD/woocommerce/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
