Skip to content

Commit 31744e0

Browse files
authored
Add script to build prod zip file (#29)
1 parent 335fb78 commit 31744e0

File tree

5 files changed

+123
-150
lines changed

5 files changed

+123
-150
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build Production Zip
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build:
8+
name: Build Production Zip
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Setup PHP
16+
uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: '7.4'
19+
tools: composer:v2
20+
coverage: none
21+
22+
- name: Get Composer cache directory
23+
id: composer-cache
24+
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
25+
26+
- name: Cache Composer dependencies
27+
uses: actions/cache@v4
28+
with:
29+
path: ${{ steps.composer-cache.outputs.dir }}
30+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
31+
restore-keys: ${{ runner.os }}-composer-
32+
33+
- name: Build production zip
34+
run: ./bin/build-prod-zip.sh
35+
36+
- name: Upload production zip artifact
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: woocommerce-product-feed-for-openai
40+
path: build/woocommerce-product-feed-for-openai
41+
if-no-files-found: error
42+
retention-days: 7

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ vendor/
2828
# Core test files
2929
tests/unit/woo
3030

31+
# Build folder
32+
build/

README.md

Lines changed: 11 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -4,158 +4,19 @@ A WooCommerce plugin that automatically generates and delivers product feeds to
44

55
## What This Plugin Does
66

7-
**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.
8-
9-
### Core Features
10-
11-
- **Complete OpenAI Specification Coverage** - All required and optional fields supported
12-
- **Real-time Updates** - Products sync within 30 seconds of changes
13-
- **Scheduled Delivery** - Automatic full feed updates every 15 minutes
14-
- **Per-Product Control** - Override global settings for individual products
15-
- **Feed Validation** - Built-in validation against OpenAI specifications
16-
- **Multiple Formats** - JSON, CSV, XML, TSV export options
17-
- **Secure API Access** - Admin-only REST endpoints for integration
7+
- **ProductFeed generation abstraction** to support the large store.
8+
- **Complete OpenAI Specification Coverage** includes:
9+
- All required and optional fields supported
10+
- Automatic full feed updates every 15 minutes
11+
- Override global settings for individual products
12+
- Built-in validation against OpenAI specifications
13+
- **Pos Catalog generation**
1814

1915
## Quick Start
2016

21-
### Installation
22-
23-
1. **Download** the latest release from GitHub Releases
17+
1. **Build and get zip file** from the latest `trunk` branch by either:
18+
- Running `npm run build` in your local env
19+
- Running [Build Production Zip](https://github.com/woocommerce/OpenAI-Product-Feed/actions/workflows/build-production-zip.yml) workflow manually for your selected branch
2420
2. **Upload** the zip file via WordPress admin (Plugins > Add New > Upload Plugin) or extract to `/wp-content/plugins/`
2521
3. **Activate** the plugin through WordPress admin
26-
4. Go to **WooCommerce > Settings > Integrations > ChatGPT**
27-
28-
### Basic Setup
29-
30-
1. **Sign Up as OpenAI Merchant**
31-
- Register at [ChatGPT Merchants](https://chatgpt.com/merchants)
32-
- Verify your feed meets OpenAI specifications
33-
34-
2. **Configure Integration Settings**
35-
- Set your Feed Delivery URL (endpoint provided by OpenAI)
36-
- Set Return Window (days)
37-
- Store identity and policy settings are managed in WooCommerce core
38-
39-
4. **Test Your Feed**
40-
- Click "Preview Feed" to see generated data
41-
- Check for validation errors
42-
- Download sample feed files
43-
44-
## How It Works
45-
46-
### Product Data Mapping
47-
48-
The plugin automatically maps your WooCommerce products to OpenAI's required format:
49-
50-
| WooCommerce Data | OpenAI Field | Notes |
51-
|------------------|--------------|-------|
52-
| Product ID | `id` | Unique identifier |
53-
| Product Name | `title` | HTML stripped |
54-
| Description | `description` | Long or short description |
55-
| Stock Status | `availability` | `in_stock`, `out_of_stock`, `preorder` |
56-
| Weight | `weight` | With unit (kg, lbs, etc.) |
57-
| Images | `image_link`, `additional_image_link` | URLs |
58-
| Categories | `product_category` | Hierarchical path |
59-
| Attributes | `color`, `size`, `material`, etc. | Product attributes |
60-
61-
### Feed Delivery Options
62-
63-
**1. Push to OpenAI (Automatic)**
64-
- Scheduled: Every 15 minutes
65-
- Delta: 30 seconds after product changes
66-
- Manual: On-demand admin trigger
67-
68-
**2. Pull via API (On-demand)**
69-
```
70-
GET /wp-json/wc/v3/openai-feed
71-
GET /wp-json/wc/v3/openai-feed?product_id=123
72-
```
73-
74-
## Product Control
75-
76-
### Global Settings
77-
Set store-wide defaults for:
78-
- **Search Visibility** - Whether products appear in ChatGPT search
79-
- **Checkout Enabled** - Whether products allow direct purchase
80-
- **Merchant Info** - Store details, policies, shipping
81-
82-
### Per-Product Overrides
83-
Override global settings for specific products:
84-
- **Disable Search** - Exclude from ChatGPT search results
85-
- **Disable Checkout** - Remove direct purchase option
86-
- **Custom Fields** - Add product-specific data (GTIN, MPN, warnings, etc.)
87-
88-
## Required vs Optional Fields
89-
90-
### Required Fields (Always Included)
91-
- `enable_search`, `enable_checkout` - AI platform flags
92-
- `id`, `title`, `description`, `link` - Basic product info
93-
- `gtin`, `brand` - Product identifiers (with fallbacks)
94-
- `availability`, `inventory_quantity` - Stock info
95-
- `weight` - Product weight
96-
97-
### Optional Fields (When Available)
98-
- **Product Details** - MPN, category, material, condition, age group
99-
- **Dimensions** - Length, width, height, combined dimensions
100-
- **Media** - Additional images, videos, 3D models
101-
- **Pricing** - Sale prices, promotional dates
102-
- **Variants** - Colors, sizes, gender targeting
103-
- **Shipping** - Methods, pickup options, SLA
104-
- **Compliance** - Warnings, age restrictions, Q&A
105-
106-
## Access
107-
108-
109-
### Endpoints
110-
```http
111-
# Get complete feed
112-
GET /wp-json/wc/v3/openai-feed
113-
114-
# Preview specific product
115-
GET /wp-json/wc/v3/openai-feed?product_id=123
116-
117-
# Response format
118-
Content-Type: application/json
119-
[
120-
{
121-
"enable_search": "true",
122-
"id": "123",
123-
"title": "Product Name",
124-
"availability": "in_stock",
125-
"weight": "1.5 kg"
126-
// ... all mapped fields
127-
}
128-
]
129-
```
130-
131-
## Validation & Troubleshooting
132-
133-
### Feed Validation
134-
- **Automatic** - Validates before every delivery
135-
- **Manual** - Test via "Preview Feed" button
136-
- **Logged** - All validation errors logged to WooCommerce logs
137-
138-
### Common Issues
139-
140-
**Missing Required Fields**
141-
- GTIN → Add `_gtin` custom field or uses fallback `'MISSING'`
142-
- Brand → Add `pa_brand` attribute or uses fallback `'Generic'`
143-
144-
**Validation Errors**
145-
- Check WooCommerce > Status > Logs (source: wpfoai)
146-
- Verify product data completeness
147-
- Test with single product preview
148-
149-
**Delivery Issues**
150-
- Confirm endpoint URL and token
151-
- Check WooCommerce logs for HTTP errors
152-
- Verify network connectivity
153-
154-
155-
### Getting Help
156-
- Check WooCommerce > Status > Logs (source: wpfoai)
157-
- Use "Preview Feed" for testing individual products
158-
- Verify all required WooCommerce data is present
159-
160-
### Logs Location
161-
WooCommerce > Status > Logs > Filter by source: `wpfoai`
22+
4. Go to **WooCommerce > Settings > Integrations > OpenAI** for OpenAI Product feed.

bin/build-prod-zip.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
3+
# Build production zip file for woocommerce-product-feed-for-openai
4+
# Exit on any error
5+
set -e
6+
7+
# Plugin slug constant
8+
PLUGIN_SLUG="woocommerce-product-feed-for-openai"
9+
10+
echo "======================================"
11+
echo "Building Production Zip"
12+
echo "======================================"
13+
14+
echo ""
15+
echo "Step 1: Creating build directory..."
16+
mkdir -p ./build
17+
18+
if [ -d "./build/${PLUGIN_SLUG}" ]; then
19+
echo "Removing existing ${PLUGIN_SLUG} directory..."
20+
rm -rf ./build/${PLUGIN_SLUG}
21+
fi
22+
23+
echo ""
24+
echo "Step 2: Creating ${PLUGIN_SLUG} fresh directory..."
25+
mkdir -p ./build/${PLUGIN_SLUG}
26+
27+
echo ""
28+
echo "Step 3: Installing production dependencies..."
29+
COMPOSER_VENDOR_DIR=./build/${PLUGIN_SLUG}/vendor composer install --no-dev --optimize-autoloader
30+
31+
echo ""
32+
echo "Step 4: Copying files and folders..."
33+
FILES_TO_COPY=(
34+
"./src"
35+
"./openai-product-feed-for-woo.php"
36+
)
37+
38+
for file in "${FILES_TO_COPY[@]}"; do
39+
cp -r "$file" ./build/${PLUGIN_SLUG}
40+
done
41+
42+
echo ""
43+
echo "Step 5: Creating zip file..."
44+
cd ./build
45+
if [ -f "${PLUGIN_SLUG}.zip" ]; then
46+
echo "Removing existing zip file..."
47+
rm ${PLUGIN_SLUG}.zip
48+
fi
49+
zip -r ${PLUGIN_SLUG}.zip ${PLUGIN_SLUG}
50+
cd ..
51+
52+
# Success message
53+
echo ""
54+
echo "======================================"
55+
echo "✓ SUCCESS!"
56+
echo "======================================"
57+
echo "Production zip file created successfully!"
58+
echo "Location: ./build/${PLUGIN_SLUG}.zip"
59+
echo "Size: $(du -h ./build/${PLUGIN_SLUG}.zip | awk '{print $1}')"
60+
61+
# Cleanup build directory when not in CI environment
62+
if [ -z "$CI" ]; then
63+
echo "Removing ./build/${PLUGIN_SLUG} directory"
64+
rm -rf ./build/${PLUGIN_SLUG}
65+
fi
66+
67+
echo "Done!"

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"license": "GPL-2.0-or-later",
1212
"scripts": {
13+
"build": "./bin/build-prod-zip.sh",
1314
"env:start": "wp-env start --update",
1415
"env:stop": "wp-env stop",
1516
"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",

0 commit comments

Comments
 (0)