If you run a WooCommerce store and want to collect extra information from customers — like a custom engraving message, a file upload for a print-on-demand product, or a color preference — you need a WooCommerce product custom fields plugin. The problem? Most premium plugins charge monthly fees, and hiring a developer to build a custom solution costs hundreds of dollars. In this guide, you will learn how to build your own fully functional, free WooCommerce product custom fields plugin from scratch using Claude AI — no deep coding knowledge required.
Copy the prompt below to create same WooCommerce product custom fields plugin using claude ai
Build a complete, installable WooCommerce Product Custom Fields WordPress plugin.PLUGIN DETAILS:
- Plugin Name: WooCommerce Product Custom Fields
- Author: Quick Tips
- Version: 1.3.0
- Text Domain: woo-custom-fields
- Requires WordPress 6.0+, WooCommerce 7.0+, PHP 7.4+════════════════════════════════════════
FILE STRUCTURE
════════════════════════════════════════
woo-custom-fields/
├── woo-custom-fields.php
├── admin/
│ ├── class-wcf-admin.php
│ ├── css/admin.css
│ └── js/admin.js
├── includes/
│ ├── class-wcf-post-meta.php
│ ├── class-wcf-frontend.php
│ └── class-wcf-order.php
└── frontend/
├── css/frontend.css
└── js/frontend.js════════════════════════════════════════
FIELD TYPES (6 total)
════════════════════════════════════════
1. Text — single-line input
2. Textarea — multi-line resizable input
3. File Upload — file input with type + size restrictions
4. Color Picker — native color input with live hex value display
5. Checkbox — multi-select, options list, per-option pricing
6. Radio Buttons — single-select, options list, per-option pricing════════════════════════════════════════
STABLE FIELD ID GENERATION (CRITICAL)
════════════════════════════════════════
This is the most important technical requirement. Failure here breaks all validation.IN JAVASCRIPT (admin.js):
When "+ Add Field" is clicked, immediately assign a unique ID to the hidden [id] input:
var newId = 'wcf_' + Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
$row.find('input[name$="[id]"]').val(newId);When "+ Add Option" is clicked for checkbox/radio, immediately assign a unique ID:
var optId = 'wcfo_' + Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
$opt.find('input[name$="[id]"]').val(optId);IN PHP (class-wcf-post-meta.php save_fields()):
NEVER use: sanitize_key($f['id'] ?? uniqid('wcf_'))
— this treats empty string '' as a valid value and never generates a real ID.ALWAYS use:
$incoming_id = isset($f['id']) ? sanitize_key($f['id']) : '';
$field_id = ($incoming_id !== '') ? $incoming_id : uniqid('wcf_');Same pattern for option IDs inside checkbox/radio options arrays:
$incoming_oid = isset($opt['id']) ? sanitize_key($opt['id']) : '';
$opt_id = ($incoming_oid !== '') ? $incoming_oid : uniqid('wcfo_');════════════════════════════════════════
ADMIN PANEL (Product Editor)
════════════════════════════════════════
Add a "Custom Fields" tab inside the WooCommerce Product Data meta box (priority 85).Each field row shows a collapsible card with:
- Header: drag handle (dashicons-menu), field label, TYPE badge, REQUIRED badge
(red, hidden by default, shows when required toggle is ON), toggle collapse button,
Remove button
- Body contains:
□ Field Type selector (Text / Textarea / File Upload / Color Picker /
Checkbox multi-select / Radio Buttons single-select)
□ Label input
□ Placeholder input (hide for Checkbox and Radio)
□ Required toggle — styled ON/OFF switch (not a plain checkbox)
- Uses CSS toggle switch with sliding handle
- Live updates the REQUIRED badge in the header on change
□ Extra Price input (currency symbol + number input)
- HIDE for: Color Picker, Checkbox, Radio (these use per-option pricing)
- SHOW for: Text, Textarea, File Upload
- Label: "Extra Price — Added to product price only if customer uses this field"
□ Display Position (Before / After Add to Cart button)
□ File Upload options block (shown only when type = File Upload):
- Allowed file types (comma-separated, default: jpg,jpeg,png,pdf,doc,docx)
- Max file size in MB (number input, default: 5)
□ Options Editor block (shown only when type = Checkbox or Radio):
- Label: "Options (each option can have its own extra price)"
- List of option rows, each with:
· Hidden id input
· Option label text input
· Currency symbol + extra price number input
· × Remove button
- "+ Add Option" button
- Auto-show options editor when switching type to Checkbox or Radio
- Auto-add one blank option row if switching to Checkbox/Radio with no options yetHidden JS templates (rendered PHP, placed in 

The AI-powered business operating system
Take Your Business To The Next Level
Get 30 Days Free Trial + Free Live Bootcamp
to Launch HighLevel Together
Share this article:
Facebook
Twitter
LinkedIn
Reddit
WhatsApp
Prashant P Mittal
Prashant Mittal is a freelance web designer with 15+ years and 1,800+ sites built. He publishes free WordPress, Elementor, WooCommerce & GoHighLevel tutorials at paramfreelance.com









