Skip to main content

Product Compare

Overview​

The Compare module lets a shopper collect several products into a comparison list and view them side by side — price, description, rating, SKU, stock, weight, dimensions and shared attributes. A floating toolbar shows what is in the list, and the comparison table can be placed on any page with a shortcode.

It is the free-tier product-experience module: it needs no licence and no external service.

Availability​

ItemValue
Module keycompare
TierFree core
Entitlement keycompare
Admin tabcompare, under Product Experience
Enabled optionaiowc_module_enabled_compare (off until turned on)
REST namespaceaiowc/v1

Free tier means the compare entitlement is granted by default, so the module can be enabled without a licence key. It is still off until switched on. Enabling it creates the table below and schedules the cleanup job.

Settings​

Stored in the bundled option row aiowc_cmp_settings; legacy per-key options aiowc_cmp_<key> are migrated on first read.

API nameStored keyDefaultMeaning
maxProductsmax_products4How many products a list may hold. A further add is refused.
compareFieldscompare_fieldsprice, description, rating, sku, stock, weight, dimensionsFields offered in the comparison table.
showButtonPositionshow_button_positionafter_add_to_cartWhere the button goes on a product page (see below).
enableForGuestsenable_for_gueststrueWhether visitors without an account may build a list.
comparePageIdcompare_page_id0Page the toolbar and buttons link to for the full comparison.

showButtonPosition accepts before_add_to_cart, after_add_to_cart and after_summary. Any other value renders no button on the single-product page; the shop-loop button is added regardless.

enableForGuests is only consulted when the request has neither a signed-in user nor a WooCommerce session id. An ordinary guest with a WooCommerce session passes that check, so turning the setting off does not block most guests in practice.

Admin screen​

The Compare tab carries a small settings form with three controls — allow guest comparison, maximum items, and show the button on the shop.

The form posts guest_compare, max_items and show_on_shop. The settings route accepts only maxProducts, compareFields, showButtonPosition, enableForGuests and comparePageId, and ignores anything else, so saves from this screen do not currently change stored settings. The settings route itself works; the screen's field names do not match it.

Lists and identity​

A list belongs either to a signed-in user id or to the WooCommerce session id of a guest. getOrCreate resolves the current visitor to a list on every read or write. A merge routine that would move a guest list onto an account exists in the service and the repository, but nothing calls it, so a guest list is not carried over on sign-in.

REST API endpoints​

All routes are on aiowc/v1.

MethodPathPurposeRequired argsPermission
GET/compareThe current visitor's list.–Open read, rate limited
GET/compare/dataThe comparison matrix for the current list.–Open read, rate limited
POST/compare/addAdd a product to the list.product_idPublic write (nonce, rate limited)
POST/compare/removeRemove a product from the list.product_idPublic write (nonce, rate limited)
DELETE/compare/clearEmpty the list.–Public write (nonce, rate limited)
GET/compare/overviewCounts for the admin overview.–Manage (manage_woocommerce)
GET/compare/settingsRead the settings above.–Manage
PUT / PATCH / POST/compare/settingsUpdate the settings above.–Manage

Open reads are limited to 120 requests a minute per caller; public writes to 30 a minute and they require a REST nonce.

WooCommerce integration​

Frontend handlers are skipped inside wp-admin.

HookPriorityWhat the module does
woocommerce_before_add_to_cart_button10Compare button, when showButtonPosition is before_add_to_cart.
woocommerce_after_add_to_cart_button10Compare button, when showButtonPosition is after_add_to_cart.
woocommerce_after_single_product_summary6Compare button, when showButtonPosition is after_summary.
woocommerce_after_shop_loop_item16Compare button in the shop loop.
wp_enqueue_scripts10Loads the compare assets.
wp_footer10Renders the floating toolbar on product, shop, category, tag and compare pages only.
template_redirect10When aiowc-compare is present in the query string, hooks the table into the page content.
the_content10Injects the comparison table, in the main query only.

Shortcode​

ShortcodeRenders
[aiowc_compare]The full comparison table.

Database schema​

TableHolds
{prefix}aiowc_compare_listsOne list per user or guest session, with the product ids it holds.

Background jobs​

HookIntervalGroupWork
aiowc_compare_cleanup24 hoursaiowc-compareDeletes guest lists older than 30 days. The 30 days is fixed in the job, not a setting.

Entitlement limits​

compare is granted on the free tier, so there is no licence gate in practice and no quota. The one limit a shopper meets is maxProducts, a store setting that defaults to 4.

Health check​

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