Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/build-production-zip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build Production Zip

on:
workflow_dispatch:

jobs:
build:
name: Build Production Zip
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer:v2
coverage: none

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Build production zip
run: ./bin/build-prod-zip.sh

- name: Upload production zip artifact
uses: actions/upload-artifact@v4
with:
name: woocommerce-product-feed-for-openai
path: build/woocommerce-product-feed-for-openai
if-no-files-found: error
retention-days: 7
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ vendor/
# Core test files
tests/unit/woo

# Build folder
build/
161 changes: 11 additions & 150 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,158 +4,19 @@ A WooCommerce plugin that automatically generates and delivers product feeds to

## What This Plugin Does

**Connects your WooCommerce store to OpenAI's ChatGPT commerce platform** by automatically generating product feeds in the [required format](https://developers.openai.com/commerce/specs/feed) and delivering them via multiple channels.

### Core Features

- **Complete OpenAI Specification Coverage** - All required and optional fields supported
- **Real-time Updates** - Products sync within 30 seconds of changes
- **Scheduled Delivery** - Automatic full feed updates every 15 minutes
- **Per-Product Control** - Override global settings for individual products
- **Feed Validation** - Built-in validation against OpenAI specifications
- **Multiple Formats** - JSON, CSV, XML, TSV export options
- **Secure API Access** - Admin-only REST endpoints for integration
- **ProductFeed generation abstraction** to support the large store.
- **Complete OpenAI Specification Coverage** includes:
- All required and optional fields supported
- Automatic full feed updates every 15 minutes
- Override global settings for individual products
- Built-in validation against OpenAI specifications
- **Pos Catalog generation**

## Quick Start

### Installation

1. **Download** the latest release from GitHub Releases
1. **Build and get zip file** from the latest `trunk` branch by either:
- Running `npm run build` in your local env
- Running [Build Production Zip](https://github.com/woocommerce/OpenAI-Product-Feed/actions/workflows/build-production-zip.yml) workflow manually for your selected branch
2. **Upload** the zip file via WordPress admin (Plugins > Add New > Upload Plugin) or extract to `/wp-content/plugins/`
3. **Activate** the plugin through WordPress admin
4. Go to **WooCommerce > Settings > Integrations > ChatGPT**

### Basic Setup

1. **Sign Up as OpenAI Merchant**
- Register at [ChatGPT Merchants](https://chatgpt.com/merchants)
- Verify your feed meets OpenAI specifications

2. **Configure Integration Settings**
- Set your Feed Delivery URL (endpoint provided by OpenAI)
- Set Return Window (days)
- Store identity and policy settings are managed in WooCommerce core

4. **Test Your Feed**
- Click "Preview Feed" to see generated data
- Check for validation errors
- Download sample feed files

## How It Works

### Product Data Mapping

The plugin automatically maps your WooCommerce products to OpenAI's required format:

| WooCommerce Data | OpenAI Field | Notes |
|------------------|--------------|-------|
| Product ID | `id` | Unique identifier |
| Product Name | `title` | HTML stripped |
| Description | `description` | Long or short description |
| Stock Status | `availability` | `in_stock`, `out_of_stock`, `preorder` |
| Weight | `weight` | With unit (kg, lbs, etc.) |
| Images | `image_link`, `additional_image_link` | URLs |
| Categories | `product_category` | Hierarchical path |
| Attributes | `color`, `size`, `material`, etc. | Product attributes |

### Feed Delivery Options

**1. Push to OpenAI (Automatic)**
- Scheduled: Every 15 minutes
- Delta: 30 seconds after product changes
- Manual: On-demand admin trigger

**2. Pull via API (On-demand)**
```
GET /wp-json/wc/v3/openai-feed
GET /wp-json/wc/v3/openai-feed?product_id=123
```

## Product Control

### Global Settings
Set store-wide defaults for:
- **Search Visibility** - Whether products appear in ChatGPT search
- **Checkout Enabled** - Whether products allow direct purchase
- **Merchant Info** - Store details, policies, shipping

### Per-Product Overrides
Override global settings for specific products:
- **Disable Search** - Exclude from ChatGPT search results
- **Disable Checkout** - Remove direct purchase option
- **Custom Fields** - Add product-specific data (GTIN, MPN, warnings, etc.)

## Required vs Optional Fields

### Required Fields (Always Included)
- `enable_search`, `enable_checkout` - AI platform flags
- `id`, `title`, `description`, `link` - Basic product info
- `gtin`, `brand` - Product identifiers (with fallbacks)
- `availability`, `inventory_quantity` - Stock info
- `weight` - Product weight

### Optional Fields (When Available)
- **Product Details** - MPN, category, material, condition, age group
- **Dimensions** - Length, width, height, combined dimensions
- **Media** - Additional images, videos, 3D models
- **Pricing** - Sale prices, promotional dates
- **Variants** - Colors, sizes, gender targeting
- **Shipping** - Methods, pickup options, SLA
- **Compliance** - Warnings, age restrictions, Q&A

## Access


### Endpoints
```http
# Get complete feed
GET /wp-json/wc/v3/openai-feed

# Preview specific product
GET /wp-json/wc/v3/openai-feed?product_id=123

# Response format
Content-Type: application/json
[
{
"enable_search": "true",
"id": "123",
"title": "Product Name",
"availability": "in_stock",
"weight": "1.5 kg"
// ... all mapped fields
}
]
```

## Validation & Troubleshooting

### Feed Validation
- **Automatic** - Validates before every delivery
- **Manual** - Test via "Preview Feed" button
- **Logged** - All validation errors logged to WooCommerce logs

### Common Issues

**Missing Required Fields**
- GTIN → Add `_gtin` custom field or uses fallback `'MISSING'`
- Brand → Add `pa_brand` attribute or uses fallback `'Generic'`

**Validation Errors**
- Check WooCommerce > Status > Logs (source: wpfoai)
- Verify product data completeness
- Test with single product preview

**Delivery Issues**
- Confirm endpoint URL and token
- Check WooCommerce logs for HTTP errors
- Verify network connectivity


### Getting Help
- Check WooCommerce > Status > Logs (source: wpfoai)
- Use "Preview Feed" for testing individual products
- Verify all required WooCommerce data is present

### Logs Location
WooCommerce > Status > Logs > Filter by source: `wpfoai`
4. Go to **WooCommerce > Settings > Integrations > OpenAI** for OpenAI Product feed.
67 changes: 67 additions & 0 deletions bin/build-prod-zip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

# Build production zip file for woocommerce-product-feed-for-openai
# Exit on any error
set -e

# Plugin slug constant
PLUGIN_SLUG="woocommerce-product-feed-for-openai"

echo "======================================"
echo "Building Production Zip"
echo "======================================"

echo ""
echo "Step 1: Creating build directory..."
mkdir -p ./build

if [ -d "./build/${PLUGIN_SLUG}" ]; then
echo "Removing existing ${PLUGIN_SLUG} directory..."
rm -rf ./build/${PLUGIN_SLUG}
fi

echo ""
echo "Step 2: Creating ${PLUGIN_SLUG} fresh directory..."
mkdir -p ./build/${PLUGIN_SLUG}

echo ""
echo "Step 3: Installing production dependencies..."
COMPOSER_VENDOR_DIR=./build/${PLUGIN_SLUG}/vendor composer install --no-dev --optimize-autoloader

echo ""
echo "Step 4: Copying files and folders..."
FILES_TO_COPY=(
"./src"
"./openai-product-feed-for-woo.php"
)

for file in "${FILES_TO_COPY[@]}"; do
cp -r "$file" ./build/${PLUGIN_SLUG}
done

echo ""
echo "Step 5: Creating zip file..."
cd ./build
if [ -f "${PLUGIN_SLUG}.zip" ]; then
echo "Removing existing zip file..."
rm ${PLUGIN_SLUG}.zip
fi
zip -r ${PLUGIN_SLUG}.zip ${PLUGIN_SLUG}
cd ..

# Success message
echo ""
echo "======================================"
echo "✓ SUCCESS!"
echo "======================================"
echo "Production zip file created successfully!"
echo "Location: ./build/${PLUGIN_SLUG}.zip"
echo "Size: $(du -h ./build/${PLUGIN_SLUG}.zip | awk '{print $1}')"

# Cleanup build directory when not in CI environment
if [ -z "$CI" ]; then
echo "Removing ./build/${PLUGIN_SLUG} directory"
rm -rf ./build/${PLUGIN_SLUG}
fi

echo "Done!"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"license": "GPL-2.0-or-later",
"scripts": {
"build": "./bin/build-prod-zip.sh",
"env:start": "wp-env start --update",
"env:stop": "wp-env stop",
"test:php": "./bin/checkout-woo-tests.sh && wp-env run --env-cwd='wp-content/plugins/woocommerce-product-feed-for-openai' tests-cli vendor/bin/phpunit -c phpunit.xml tests/unit/ProductFeed",
Expand Down