OptionGrid Variation Matrix for WooCommerce

Show every WooCommerce product variation at once in a grid or matrix layout, with quantity boxes and a single bulk add-to-cart button.

Version 1.0.0 By Girish Sharma GPLv2 or later

1. Requirements

WordPress5.0 or higher (tested up to 7.1)
WooCommerce4.0 or higher (tested up to 11.1)
PHP7.4 or higher
Product typeVariable products with at least one published variation

The plugin declares compatibility with WooCommerce High-Performance Order Storage (HPOS) and the cart and checkout blocks.

2. Installation

Install WooCommerce first — OptionGrid Variation Matrix will not activate without it.

From the WordPress admin

  1. Go to Plugins → Add New → Upload Plugin.
  2. Choose optiongrid-variation-matrix.zip and select Install Now.
  3. Select Activate Plugin.

By FTP

  1. Unzip optiongrid-variation-matrix.zip.
  2. Upload the optiongrid-variation-matrix folder to /wp-content/plugins/.
  3. Activate the plugin from the Plugins screen.
Upload the plugin folder, not the whole download If your download contains a documentation folder alongside the plugin, upload only the optiongrid-variation-matrix folder.

3. Quick start

  1. Edit a variable product that already has variations.
  2. In the Product data panel, open the Variation Matrix tab.
  3. Tick Enable Variation Matrix.
  4. Choose a Layout Type and the details you want to show.
  5. Select Update, then view the product on the front end.

The standard WooCommerce attribute dropdowns are replaced by the matrix. Customers type quantities next to the variations they want and select Add Selected to Cart once.

The tab only appears on variable products If you cannot see the Variation Matrix tab, set the product type to Variable product and add at least one variation first.

4. Layouts

Layout Description Best for
Grid A card per variation with image, name, price, stock and a quantity box. The number of columns and the spacing are configurable. Products where the image matters, and small variation counts.
Matrix A two dimensional table with the first attribute down the side and the second across the top. Size against colour, and other two-attribute products.
The matrix layout needs two attributes A product with only one variation attribute cannot be drawn as a matrix. In that case the plugin shows the standard WooCommerce form instead, and displays an explanatory message to logged in users who can edit products. Choose the grid layout for such products.

5. Pro version

OptionGrid Variation Matrix Pro adds the Table layout, with one row per variation and a column for each attribute, and a live Order Totals bar showing the total items, weight and price of the quantities entered. The bar sits above the Add Selected to Cart button, and each figure can be switched on or off per product.

Pro shares its product settings, options and theme template overrides with the free version, and deactivates the free version automatically when it is activated, so nothing needs reconfiguring. It is available from wpintegrate.com.

6. Product settings

All settings below live in the Variation Matrix tab of the Product data panel and apply to that product only.

SettingDescriptionDefault
Enable Variation MatrixTurns the matrix on for this product.Off
Layout TypeGrid or Matrix.Grid
Grid ColumnsMaximum number of grid columns, from 1 to 6. Fewer columns are used automatically when the space the grid sits in is too narrow to give each card a usable width.3
Grid Spacing (px)Gap between grid items, from 0 to 50. Grid layout only.10
Show Variation ImagesShows the variation image, falling back to the parent product image.On
Show AttributesShows the attribute name and value for each variation.On
Show PriceShows the variation price, including sale prices.On
Show Stock StatusShows availability, with low stock warnings.On
Show SKUShows the variation SKU.Off
Show DescriptionShows the variation description. Honoured by both layouts.Off
HeadingReplaces the heading above the variations for this product only. Leave empty to use the site wide setting.Empty
Intro TextReplaces the line of text under the heading for this product only. Leave empty to use the site wide setting.Empty
Custom CSS ClassUp to five extra class names added to the container, for your own styling.Empty
Empty means “inherit”, not “blank” Clearing the Heading or Intro Text field makes the product fall back to the site wide setting, and then to the default wording for the layout. The field's placeholder shows the text it will inherit.

Stock and quantity handling

  • Quantity fields are limited by each variation's available stock and its minimum and maximum purchase quantity. The minimum is enforced on the field and again when adding to the cart.
  • Out of stock variations cannot be ordered and their quantity field is disabled or hidden.
  • Backorders are permitted when WooCommerce is configured to allow them.
  • The low stock threshold follows WooCommerce → Settings → Products → Inventory.
  • A single request may add up to 100 different variations to the cart.

7. Global settings

Go to WooCommerce → Variation Matrix, or use the Settings link on the plugin's row on the Plugins screen. These options apply to every product that uses a variation layout.

General

SettingDescriptionDefault
Delete Data on Uninstall When set to Yes, all plugin options and per-product settings are permanently removed when the plugin is deleted from the Plugins screen. Deactivating alone never deletes anything. No

Heading & Text

Controls the heading and the line of text shown above the variations.

SettingDescriptionDefault
Heading Block Show the heading and intro text, or hide both. Hide them when your theme or page layout already introduces the section. Show
Heading The heading used on every product. Leave empty to keep each layout's own default. Empty
Intro Text The line under the heading. Leave empty to keep each layout's own default. Empty

Each field is resolved independently, in this order:

  1. The product's own Heading or Intro Text, from its Variation Matrix tab.
  2. The site wide value set here.
  3. The built-in default for the layout being drawn.

The built-in defaults are:

LayoutHeadingIntro text
GridSelect VariationsChoose quantities for the variations you want to add to cart:
MatrixProduct Variations MatrixEnter the quantities you need for each Size and Colour combination.

Basic inline formatting such as <strong> and <a> is allowed in both fields, up to 500 characters. In the intro text of the matrix layout you can also use two placeholders:

PlaceholderReplaced with
{row_attribute}The attribute drawn down the side, for example Size.
{column_attribute}The attribute drawn across the top, for example Colour.
The placeholders only have a value in the matrix layout The grid layout has no axes, so the placeholders resolve to nothing there. Use them only in text you expect to appear on a matrix product, or set that wording on the product itself.

Styling

Decides whether the plugin styles the layouts itself or leaves that to your theme.

SettingDescriptionDefault
Stylesheet Plugin styling loads the full plugin design, tuned by the colour and typography options below.
Minimal loads only the structural rules the layouts cannot work without — grid columns, horizontal scrolling, fixed matrix columns and screen reader text — and leaves every colour, border and font to your theme.
Theme styling loads no plugin CSS at all, apart from the single rule that keeps screen reader labels hidden.
Plugin styling
Accent ColourButtons, focus rings and selected cells.#2563eb
Accent Text ColourText and icons drawn on top of the accent colour.#ffffff
Text ColourHeadings, prices and attribute labels.#1f2937
Secondary Text ColourSKUs, descriptions and other supporting text.#6b7280
Border ColourMatrix grid lines, card outlines and input borders.#e5e7eb
Header BackgroundBackground of the matrix header cells.#f8fafc
Cell BackgroundBackground of matrix cells and grid cards.#ffffff
Base Font Size11–20px. Every other size in the layouts scales from this value.14px
Corner Radius0–24px. Set to 0 for square corners.8px
Your colours are kept when you switch to Theme styling The colour and typography fields are ignored in that mode, but their values are preserved and used again as soon as you switch back.

8. Template overrides

Every layout is a template file you can override from your theme. Copy the file you want to change from:

wp-content/plugins/optiongrid-variation-matrix/public/templates/

into a wc-variation-matrix folder in your child theme:

wp-content/themes/your-child-theme/wc-variation-matrix/wcvm-variation-matrix-grid.php
wp-content/themes/your-child-theme/wc-variation-matrix/wcvm-variation-matrix-matrix.php

The child theme is checked first, then the parent theme, then the plugin.

Variables available in a template

VariableContents
$productThe current WC_Product object.
$variationsArray of processed variations, ready for display.
$processed_variationsAlias of $variations, kept for backward compatibility.
$settingsResolved display settings for the product.
$matrixMatrix axes and lookup map. Matrix layout only.

Keys in $settings

KeyContents
layoutgrid or matrix.
columns, spacingGrid column maximum and gap in pixels.
show_image, show_attributes, show_price, show_stock, show_sku, show_descriptionDisplay options, each yes or no.
show_headingBoolean. Whether the heading block is drawn at all.
heading, introResolved heading and intro text, ready to print with wp_kses_post(). Either may be an empty string.
style_modefull, minimal or none.
custom_cssThe product's custom CSS class names.
product_idThe parent product ID.
A copied template stops receiving updates Once a template lives in your theme, that copy is used instead of the plugin's and will not pick up improvements from future plugin releases. Recopy it and reapply your changes when you update, or keep your customisation in CSS where you can.

Keys in each entry of $variations

KeyContents
variation_idVariation ID.
skuVariation SKU.
formatted_nameAttribute values joined with a dash.
attributesAttribute label to display value, for output.
attributes_rawAttribute slug to display value, for lookups.
price_htmlFormatted price markup from WooCommerce.
priceThe numeric price the customer sees, following the shop tax display setting.
regular_price, sale_price, is_on_salePricing details.
is_in_stock, is_purchasableAvailability flags.
stock_status, stock_class, stock_quantityStock text, CSS state class and quantity.
min_qty, max_qtyPurchase quantity bounds.
image_urlThumbnail URL, falling back to the parent product.
weight, dimensions, descriptionAdditional variation data.
Always escape output in your templates Use esc_html(), esc_attr() and esc_url() for text values, and wp_kses_post() for price_html and description.

9. Styling

All CSS classes are prefixed with wcvm-, so nothing collides with your theme. Which stylesheet loads depends on the Stylesheet setting described in Global settings:

ModeFile loaded
Plugin stylingpublic/assets/css/wcvm-frontend.css
Minimalpublic/assets/css/wcvm-frontend-minimal.css
Theme stylingNone.

Colour and size tokens

Every colour, size and radius in the plugin stylesheet comes from a CSS custom property declared on .wcvm-variation-matrix. The settings screen writes your values into an inline block that redeclares the same properties, which is why no rule in the stylesheet needs a hard coded colour — and why you can override any of them yourself:

.wcvm-variation-matrix {
    --wcvm-accent: #0a5c36;          /* buttons, focus rings, selected cells */
    --wcvm-accent-rgb: 10, 92, 54;   /* the same colour as an RGB triplet    */
    --wcvm-accent-contrast: #ffffff; /* text drawn on the accent colour      */
    --wcvm-text: #1f2937;
    --wcvm-muted: #6b7280;
    --wcvm-border: #e5e7eb;
    --wcvm-head-bg: #f8fafc;
    --wcvm-surface: #ffffff;
    --wcvm-font-size: 14px;
    --wcvm-radius: 8px;
}

Set --wcvm-accent-rgb alongside --wcvm-accent: the translucent focus rings and selected-cell tints are built from it.

Two further tokens are not exposed in the settings screen, but you can set them yourself:

TokenPurposeDefault
--wcvm-cell-minNarrowest a matrix cell may become before the matrix scrolls sideways.170px
--wcvm-axis-widthWidth of the matrix attribute column down the left side.118px

Status colours use --wcvm-success, --wcvm-warning and --wcvm-danger, each with a matching -bg variant.

Adding your own rules

Do not edit the plugin stylesheet directly — your changes would be lost on update. Add your rules to your child theme stylesheet or the Additional CSS panel of the WordPress Customizer or Site Editor, and use the per-product Custom CSS Class setting to target one product:

/* With "my-wholesale-grid" set as the custom CSS class */
.my-wholesale-grid .wcvm-grid-item {
    border-color: #0a5c36;
}

Useful classes

ClassElement
.wcvm-variation-matrixOuter container, present on every layout. Also carries .wcvm-style-full, .wcvm-style-minimal or .wcvm-style-none.
.wcvm-headerThe heading and intro block above the variations.
.wcvm-grid-itemA single card in the grid layout.
.wcvm-grid-footerPrice, stock and quantity, pinned to the bottom of a card.
.wcvm-matrix-variationA single cell in the matrix layout.
.wcvm-matrix-buyThe quantity box and add button inside a matrix cell.
.wcvm-matrix-corner, .wcvm-row-header, .wcvm-col-headerThe matrix axis headers.
.wcvm-qty-inputA quantity field.
.wcvm-bulk-add-to-cartThe bulk add-to-cart button.
.wcvm-stock-status, .wcvm-matrix-stockThe stock badge.
.wcvm-in-stock, .wcvm-low-stock, .wcvm-out-of-stockStock state modifiers.
.wcvm-has-quantityAdded while a quantity above zero is entered.

Grid columns

The grid reads two CSS custom properties, so you can override them from your own stylesheet:

.wcvm-grid {
    --wcvm-columns: 4;   /* columns when there is room for them */
    --wcvm-gap: 24px;
}

The grid shows exactly the number of columns you configure. It drops to fewer only when the container it sits in is too narrow to give each card roughly 150px, stepping down at container widths of 1000px, 830px, 660px, 490px and 320px. The measurement is of the container, not the browser window, because WooCommerce usually places the product summary beside the gallery: on a 900px screen that column can be as narrow as 250px, which a window-width rule would never notice.

This uses CSS container queries. Browsers without them (Chrome before 105, Safari before 16, Firefox before 110) fall back to fitting as many 150px cards as the row allows.

Wide layouts

The matrix layout scrolls sideways inside its own container rather than squashing its columns. It keeps its attribute column pinned to the left edge, so the row labels stay visible while the rest scrolls.

10. Hooks & filters

Actions

HookArgumentsFires
wcvm_before_render_matrix$product, $settingsBefore the markup is output.
wcvm_before_bulk_actions$settings, $variations, $productInside every layout template, between the variations and the add-to-cart button.
wcvm_after_render_matrix$product, $settingsAfter the markup is output.

Filters

HookArgumentsPurpose
wcvm_is_enabled_for_product$enabled, $product_idForce the matrix on or off for a product.
wcvm_product_settings$settings, $product_idChange the resolved display settings.
wcvm_processed_variation$data, $variation_objAdd to or change a single variation's data.
wcvm_locate_template$template, $layoutLoad a template from elsewhere.
wcvm_matrix_output$output, $productFilter the final markup.
wcvm_labels$labels, $product_id, $layout, $contextChange the resolved heading and intro text.
wcvm_style_mode$modeForce full, minimal or none at runtime.
wcvm_inline_css$css, $modeChange the inline CSS printed after the stylesheet.

Examples

Force the matrix layout for every product in one category:

add_filter( 'wcvm_product_settings', function ( $settings, $product_id ) {
    if ( has_term( 'clothing', 'product_cat', $product_id ) ) {
        $settings['layout'] = 'matrix';
    }

    return $settings;
}, 10, 2 );

Hide the matrix from logged out visitors:

add_filter( 'wcvm_is_enabled_for_product', function ( $enabled ) {
    return is_user_logged_in() ? $enabled : false;
} );

JavaScript

The front-end script exposes window.WCVM and triggers wcvm_cart_updated on document.body after a successful add to cart:

jQuery( document.body ).on( 'wcvm_cart_updated', function ( event, data ) {
    console.log( 'Cart now holds', data.cart_count, 'items' );
} );

11. Troubleshooting

The matrix is not showing on the product page

  • Confirm the product type is Variable product and that it has at least one published, purchasable variation.
  • Confirm Enable Variation Matrix is ticked and the product has been updated.
  • Sign in as an administrator and reload the product page — if something is blocking the matrix, an explanatory message is shown to users who can edit products.

Attribute values show as slugs, such as "dark-blue"

The plugin resolves term names from your attribute taxonomies, so this normally points at a stale cache. Clear any page or object cache and reload. If it persists, check that the attribute terms still exist under Products → Attributes.

Add to cart does nothing, or reports a security failure

This is almost always full page caching serving a stale security token to logged out visitors. Exclude product pages from your page cache, or configure the cache to skip pages containing a WooCommerce cart form.

The layout looks wrong in my theme

Some themes style tables and buttons aggressively. First try WooCommerce → Variation Matrix → Styling and set Stylesheet to Minimal, which keeps the layout working but hands every colour, border and font back to your theme. If your theme styles the matrix completely, choose Theme styling. Otherwise add your own overrides in the child theme using the classes listed in Styling, or copy the template into your theme and adjust the markup.

My colours are not being applied

The colour and typography options only apply in Plugin styling mode. In Minimal and Theme styling the plugin does not draw those colours at all, so the fields are shown dimmed on the settings screen. Your saved values are kept and used again when you switch back.

I changed the heading but the product still shows the old text

A per-product Heading or Intro Text on the Variation Matrix tab always wins over the site wide setting. Clear the product field to fall back to the site wide value. If nothing changes at all, clear any page cache.

My changes to the layout are not appearing

If you have copied a template into your theme, that copy is used instead of the plugin's own and will not gain new features until you recopy it. Check wp-content/themes/your-theme/wc-variation-matrix/ for old copies.

Mini cart does not update

The plugin refreshes the standard WooCommerce cart fragments. If your theme uses a custom mini cart it may listen for a different event — hook wcvm_cart_updated or added_to_cart and refresh it yourself.

A conflict with another plugin

Deactivate other plugins one at a time and switch temporarily to Storefront to identify the source, then get in touch with the details.

12. Uninstalling

Deactivating the plugin never deletes anything — your product settings are preserved and reappear when you reactivate.

Data is only removed when both of the following are true:

  1. Delete Data on Uninstall is set to Yes under WooCommerce → Variation Matrix.
  2. The plugin is deleted from the Plugins screen, not merely deactivated.

When both apply, all plugin options and every _wcvm_* product setting are permanently removed. On a multisite network this runs for each site.

This cannot be undone Take a database backup before deleting the plugin with this option turned on.

13. Changelog

1.0.0

  • Initial release.

14. Support

When reporting a problem, please include your WordPress version, your WooCommerce version, your PHP version, your active theme, and the steps that reproduce it. A link to an affected product page helps a great deal.

Visit plugins.wpintegrate.com/contact-us to get in touch.