WP Manifestindependent plugin directory
manifest / ecommerce / woocommerce-simple-product-field

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

★ 0stars
0forks

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.zip

A 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

  1. Upload the plugin files to /wp-content/plugins/woocommerce-simple-product-field/
  2. Activate the plugin through the 'Plugins' menu in WordPress
  3. Edit any product and navigate to the "Custom Field" tab
  4. Enable and configure the custom field for that product

Usage

Enabling a Custom Field

  1. Go to Products → Edit a product
  2. Click the Custom Field tab in the Product Data section
  3. Check Enable Custom Field
  4. 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)
  5. 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 field
  • woocommerce_add_to_cart_validation - Validate required fields
  • woocommerce_add_cart_item_data - Save to cart
  • woocommerce_get_item_data - Display in cart/checkout
  • woocommerce_checkout_create_order_line_item - Save to order
  • woocommerce_product_data_tabs - Add product tab
  • woocommerce_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:

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