Skip to main content

Custom Product Fields

Overview​

Custom Product Fields adds structured fields to products that the store itself owns — an ISBN, a material, a warranty period, a supplier code. Unlike Product Add-Ons, these are not questions asked of the customer and they do not change the price: they are attributes of the product, filled in by whoever edits it.

A field is defined once with a key, a type and its validation rules, then filled in per product from a panel on the product edit screen. Values can be displayed on the product page and made searchable through the WooCommerce products REST query.

It is for stores whose catalogue carries data WooCommerce has no field for.

Availability​

ItemValue
Module keycustom-fields
TierPremium
Entitlement keycustom-fields
Admin tabcustom-fields
Enabled optionaiowc_module_enabled_custom-fields (off until turned on)
REST namespaceaiowc/v1

Enabling the module creates the two tables below and seeds the defaults.

registerHooks() returns early when the licence does not grant custom-fields. The REST routes and the product edit panel always register; the two optional handlers register only when their setting is on.

Settings​

Stored in the bundled option row aiowc_cf_settings.

Stored keyDefaultMeaning
allow_frontend_displaytrueWhether fields marked for display are printed on the single product page.
search_custom_fieldstrueWhether fields marked searchable are included in the WooCommerce products REST query.

Each setting switches a whole handler on or off, so turning one off removes its hooks from the request rather than hiding output later.

Fields​

A field definition carries:

FieldMeaning
name, labelThe internal name and the label shown to whoever fills it in.
field_keyThe stable key the value is stored and queried under.
field_typeThe control used. Defaults to text.
optionsThe choices, for a field type that has them.
validation_rulesThe rules applied to a submitted value.
is_searchableWhether the value participates in product search.
is_frontend_displayWhether the value is shown on the product page. On by default.
scopeWhat the field attaches to. Defaults to product.
applies_toNarrows the field to particular products or categories.
sort_orderThe order fields appear in on the edit panel.

A value is stored per product, and optionally per variation, so a variable product can carry a different value on each variation.

Admin screen​

The Custom Fields tab defines the fields — creating, editing, deleting and bulk-editing them. The values themselves are filled in elsewhere: the module adds its own tab and panel to the WooCommerce product edit screen, and saves what is entered there on woocommerce_process_product_meta.

REST API endpoints​

All routes are on aiowc/v1 and answer with the { success, data, message } envelope.

MethodPathPurposePermissionRequired args
GET/custom-fieldsEvery field definition.manage_woocommerce–
POST/custom-fieldsCreate a field definition.manage_woocommercename, key, label, field_type
PATCH/custom-fields/{id}Update a field definition.manage_woocommerceid
DELETE/custom-fields/{id}Delete a field definition and its values.manage_woocommerce–
POST/custom-fields/bulkApply an action to several definitions at once.manage_woocommerce–
GET/products/{id}/fieldsThe field values for one product.Public, rate-limitedid
PUT/products/{id}/fieldsWrite the field values for one product.edit_productsid

The write route requires edit_products rather than manage_woocommerce, so a shop editor who may edit products can fill in field values without being given full store management.

WooCommerce integration​

HookWhat the module does
woocommerce_product_data_tabsAdds the custom-fields tab to the product edit screen.
woocommerce_product_data_panelsDraws the fields in that tab.
woocommerce_process_product_metaSaves the entered values when the product is saved.
woocommerce_product_meta_endPrints displayable values on the single product page.
woocommerce_rest_product_object_queryExtends the products REST query so searchable fields can be filtered on.

Database schema​

TableHolds
{prefix}aiowc_custom_fieldsThe field definitions: name, key, label, type, options, validation rules, searchable and display flags, scope, targeting, sort order.
{prefix}aiowc_custom_field_valuesThe values: the field, the product, optionally the variation, and the value itself.

Background jobs​

This module schedules no background jobs.

Action hooks for integrators​

HookFired when
aiowc_track_eventThe module is enabled or disabled.

Entitlement limits​

custom-fields is an on/off grant with no cap on the number of definitions or values.

Health check​

The module reports a warning when its tables are missing or WooCommerce is inactive, and otherwise reports that it is functioning normally. A disabled module reports that it is disabled.

Known gaps​

  • Deleting a field definition removes its stored values with it; there is no archive and no export first.
  • is_searchable only reaches the WooCommerce REST product query. It does not extend the ordinary storefront search box, so a field marked searchable is not necessarily findable by a shopper typing into the site's search.
  • The module offers no filter for adding a field type or a validation rule of its own.
  • There is no bulk fill: values are entered product by product on the edit screen, or written one product at a time over REST.