WooCommerce Simple Product Field
A lightweight, high-performance plugin to add custom text fields to WooCommerce products. Perfect for engraving, personalization, or custom messages.
by Lasse Jellum · github.com/nytafar/woocommerce-simple-product-field · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/nytafar/woocommerce-simple-product-field/archive/refs/heads/main.zipA lightweight, high-performance WordPress plugin that adds customizable text fields to WooCommerce products. Perfect for engraving, personalization, gift messages, or any custom text input needs.
Features
- Per-Product Configuration: Enable custom fields on specific products only
- Flexible Settings: Customize label, placeholder, description, and character limits
- Optional or Required: Make fields required or optional per product
- Cart & Checkout Display: Custom text appears throughout the purchase flow
- Order Integration: Field data is saved to orders (HPOS compatible)
- Performance Optimized: Code only executes where needed
- Clean UI: Modern, responsive field styling
- Client-side Validation: Instant feedback for required fields
- WooCommerce Standards: Uses native WooCommerce functions and hooks
Installation
- Upload the plugin files to
/wp-content/plugins/woocommerce-simple-product-field/ - Activate the plugin through the 'Plugins' menu in WordPress
- Edit any product and navigate to the "Custom Field" tab
- Enable and configure the custom field for that product
Usage
Enabling a Custom Field
- Go to Products → Edit a product
- Click the Custom Field tab in the Product Data section
- Check Enable Custom Field
- Configure the field settings:
- Field Label: The label shown above the field
- Placeholder Text: Hint text inside the field
- Field Description: Optional help text below the field
- Required Field: Make the field mandatory
- Maximum Length: Character limit (default: 100)
- Save the product
Field Settings
- Field Label: Default is "Custom Text"
- Placeholder: Default is "Enter your custom text..."
- Description: Optional additional information
- Required: Prevents adding to cart without input
- Max Length: Limits character count (1-999)
Technical Details
Architecture
The plugin follows WordPress and WooCommerce best practices:
- Singleton Pattern: Main plugin class uses singleton pattern
- Modular Design: Separate classes for frontend, cart, order, and admin
- Conditional Loading: Admin classes only load in admin, frontend only on frontend
- HPOS Compatible: Fully compatible with WooCommerce High-Performance Order Storage
File Structure
woocommerce-simple-product-field/
├── woocommerce-simple-product-field.php # Main plugin file
├── uninstall.php # Cleanup on uninstall
├── README.md # This file
└── includes/
├── class-wcspf-frontend.php # Frontend field display
├── class-wcspf-cart.php # Cart handling
├── class-wcspf-order.php # Order meta storage
└── admin/
├── class-wcspf-admin.php # Admin functionality
└── class-wcspf-product-settings.php # Product edit interface
Hooks & Filters
The plugin uses standard WooCommerce hooks:
woocommerce_before_add_to_cart_button- Display fieldwoocommerce_add_to_cart_validation- Validate required fieldswoocommerce_add_cart_item_data- Save to cartwoocommerce_get_item_data- Display in cart/checkoutwoocommerce_checkout_create_order_line_item- Save to orderwoocommerce_product_data_tabs- Add product tabwoocommerce_process_product_meta- Save product settings
Database Storage
Product Meta (per product):
_wcspf_enable_field- Enable/disable field_wcspf_field_label- Field label_wcspf_field_placeholder- Placeholder text_wcspf_field_description- Help text_wcspf_field_required- Required flag_wcspf_field_maxlength- Character limit
Order Item Meta:
{Field Label}- Visible custom text value_wcspf_custom_text- Hidden internal reference
Performance
The plugin is optimized for performance:
- Conditional Execution: Code only runs where needed
- No Global Queries: Uses targeted meta queries
- Minimal Assets: Inline CSS/JS only on relevant pages
- No External Dependencies: Pure PHP/JavaScript
- Efficient Hooks: Uses appropriate priority levels
Compatibility
- WordPress: 5.6+
- PHP: 7.4+
- WooCommerce: 5.0+
- HPOS: Fully compatible
- Multisite: Compatible
Support
For support, feature requests, or bug reports:
- Author: Lasse Jellum
- Website: https://jellum.net/
Changelog
1.0.0
- Initial release
- Per-product custom text fields
- Configurable labels, placeholders, and descriptions
- Optional or required fields
- Character limit control
- Cart and checkout display
- HPOS-compatible order storage
- Clean, modern UI
License
GPL v2 or later