Skip to main content

Enhanced Product Variations

Overview​

The Variations module does three things to WooCommerce's variable products: it replaces attribute dropdowns with swatches, it shows the selected variation's price, stock and description under the variations form, and it lets variation fields be edited in bulk instead of one variation at a time.

It is for stores whose products vary by colour, material or size, where a row of colour chips reads better than a <select>, and where a catalogue has enough variations that editing them individually is impractical.

Swatches are attached to attribute terms, not to products, so one swatch definition covers every product using that term.

Availability​

ItemValue
Module keyvariations-enhanced
TierPremium
Entitlement keyvariations-enhanced
Admin tabvariations-enhanced, under Product Experience
Enabled optionaiowc_module_enabled_variations-enhanced (off until turned on)
REST namespaceaiowc/v1

Enabling the module creates the two tables below and seeds the defaults. Uninstalling drops the tables and deletes the settings row. registerHooks() returns immediately when the licence does not grant variations-enhanced.

Settings​

Stored in the bundled option row aiowc_ve_settings.

Stored keyDefaultMeaning
enable_swatchestrueRegister the swatch renderer. Off leaves WooCommerce's dropdowns alone.
swatch_sizemediumSize class applied to the rendered swatches.
enable_tooltipstrueShow a swatch's tooltip text on hover.
show_variation_stocktrueShow the selected variation's availability under the form.
show_variation_pricetrueShow the selected variation's price under the form.
enable_bulk_updatetrueRegister the bulk-update control on the product edit screen.

enable_swatches and enable_bulk_update are read once, when hooks are registered. When both show_variation_stock and show_variation_price are off, the details block is not printed at all.

Swatch types​

TypeRendered asField used
colorA colour chip.color_value, validated as a 3- or 6-digit hex value.
imageA thumbnail.image_url
buttonA labelled button.button_label
labelA text label.button_label

Each swatch also carries an optional tooltip and a sort order, and is unique on the attribute slug plus term id.

Admin screen​

The Enhanced Product Variations tab has two sub-tabs, and exists because the module's administrator routes had no caller.

Swatches creates, edits and deletes swatches for an attribute — POST, PATCH and DELETE on /variations/swatches.

Variation data edits variation metadata: PATCH /variations/{id}/meta for one variation and POST /variations/bulk-update for many.

Swatches can also be edited where the terms live: the module adds swatch fields to the add-term and edit-term forms of every WooCommerce product attribute taxonomy, so a colour swatch can be set while creating the colour term.

Bulk update​

POST /variations/bulk-update takes a list of updates and applies only these fields; anything else in an update is ignored:

price, regular_price, sale_price, stock_quantity, stock_status, sku, description, weight, dimensions, custom_meta.

stock_status accepts instock, outofstock or onbackorder. Custom metadata is written to the module's own variation-meta table rather than to post meta.

REST API endpoints​

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

MethodPathPurposePermissionRequired args
GET/variations/{id}/metaRead a variation's extra metadata.Open read, 120 a minuteid
PATCH/variations/{id}/metaWrite a variation's extra metadata.edit_productsid, fields
POST/variations/bulk-updateApply the allowed fields across many variations.edit_productsupdates
GET/variations/swatches/{attribute_slug}List the swatches on an attribute.Open read, 120 a minuteattribute_slug
POST/variations/swatchesCreate a swatch.manage_woocommerceattribute_slug, term_id, swatch_type
PATCH/variations/swatches/{id}Update a swatch.manage_woocommerceid
DELETE/variations/swatches/{id}Delete a swatch.manage_woocommerceid

The two write routes on variation data require edit_products rather than manage_woocommerce, so a shop manager or editor who may edit products can use them.

WooCommerce integration​

HookWhat the module does
woocommerce_dropdown_variation_attribute_options_htmlReplaces the attribute dropdown with swatches when that attribute has any.
woocommerce_after_variations_formPrints the price, stock and description block, filled in by the found_variation event.
wp_enqueue_scriptsEnqueues the swatch stylesheet and script, on product pages only.
admin_initAttaches swatch fields to every product attribute taxonomy's term forms.
created_pa_* / edited_pa_*Saves the swatch fields with the term.
woocommerce_product_options_general_product_dataDraws the bulk-update control on the product edit screen.
admin_enqueue_scriptsEnqueues that control's assets.

An attribute with no swatches is left alone — the filter returns WooCommerce's own markup unchanged.

Database schema​

TableHolds
{prefix}aiowc_variation_swatchesOne row per attribute term: type, colour, image URL, button label, tooltip, sort order. Unique on attribute slug plus term id.
{prefix}aiowc_variation_metaExtra per-variation metadata as key and value, unique on variation id plus key.

Background jobs​

None. The module has no scheduled work, and onDisable() only records the event.

Entitlement limits​

variations-enhanced is an on/off grant with no numeric cap. There is no limit on the number of swatches, variations or bulk updates.

Health check​

The module reports a warning when its tables are missing or WooCommerce is inactive. Otherwise it reports that it is functioning normally.

Known gaps​

  • The variation details block is filled by an inline script bound to WooCommerce's found_variation jQuery event, so it depends on the default variations form; a theme that replaces that form will not populate it.
  • swatch_size is passed to the renderer as a class name; the module ships one stylesheet and does not otherwise validate the value.