Eren Labs JOURNAL TR
Product Catalog

WooCommerce Default Variation: Set It, Link to It, and Avoid the Dead End

A default variation makes the product page open with a colour and size already chosen. Where to set it, how a link can preselect a different one, how to set defaults in bulk or in code, and the out-of-stock case that greets shoppers with an error.

In this article9 sections

To set a default variation in WooCommerce, edit the variable product, open Product data → Variations, and choose a value for each attribute under Default Form Values. Update the product, and its page opens with that colour and size already selected, its price, stock and image showing. That is the whole setting. The rest of this guide covers what decides the selection (a link can override it), how to set defaults on many products at once, and the case where a default does more harm than good. Everything here was checked against WooCommerce’s code, version 11.3.1.

Why set a default variation at all#

A variable product page normally opens with every dropdown on “Choose an option”, the price shown as a range and the Add to cart button inactive. Shoppers who click it without choosing get the message “Please select some product options before adding this product to your cart”. A default removes that step for the most common choice:

  • The real price shows straight away instead of a range, which matters when the range is wide. Our guide to the variable product price range covers the other ways to deal with “From” prices.
  • The main image matches a product you actually sell, if the variation has its own image, rather than a generic parent photo.
  • One-click buying works for the bestseller: the button is ready the moment the page loads.

It also has a cost. A preselected size can be added to the cart by someone who never noticed it was there. For clothing and shoes, many shops preselect the colour (which the photo already shows) and leave the size for the shopper to choose.

How to set a default variation, step by step#

  1. Go to Products and edit the variable product.
  2. In the Product data box, open the Variations tab. At the top you will see Default Form Values, with one dropdown per attribute used for variations.
  3. Choose a value in each dropdown, for example Blue and Medium. To preselect only some attributes, leave the others on “No default”.
  4. Click Update. The defaults are saved with the product, not with a variation.

To remove a default, set every dropdown back to “No default” and update. If the Variations tab shows no Default Form Values at all, the product has no variations yet, or its attributes aren’t ticked “Used for variations”; our guide to attributes and variations explains the difference.

What actually decides the selected variation#

For each attribute dropdown, WooCommerce’s template function looks in two places, in this order:

  1. The page address. If the URL carries a parameter named after the attribute, such as ?attribute_pa_colour=red, that value is selected.
  2. The product’s default. Only when the URL says nothing does the Default Form Values setting apply.

That first step is useful on its own. You can link straight to the red version of a product from an email, an ad or a colour swatch on a landing page, whatever its default is. The parameter name is attribute_ followed by the attribute’s slug: global attributes (set up under Products → Attributes) have slugs starting with pa_ and take the term slug as the value, such as attribute_pa_size=xl; custom attributes typed on the product use their name, such as attribute_size=XL. Combine several with &.

Once values are selected, WooCommerce’s script on the product page finds the matching variation and shows its price, stock and image. If no available variation matches, it shows “Sorry, no products matched your selection. Please choose a different combination.” That message is the key to the next section.

When a default variation becomes a dead end#

Illustration: a default variation that is in stock opens ready to buy, one that is out of stock opens on an error
A default is only helpful while that variation can be bought. When it sells out, the page opens on a dead end.

A default points at attribute values, not at a variation, and it doesn’t change when stock does. So the page can open on a combination the shopper can’t buy:

The default variation is…What the shopper sees on page load
In stock, enabled, pricedPrice, stock and image of that variation, button ready
Out of stock“Out of stock” under the dropdowns, button inactive
Out of stock, with “Hide out of stock items from the catalog” on“Sorry, no products matched your selection”, because hidden variations are left out of the list
Disabled, or with an empty priceThe same “no products matched” message: WooCommerce leaves those out too
DeletedThe same message, until the default is changed

All three bottom rows look like a broken product to a shopper, and none of them shows up in the admin. Two habits prevent them. When a variation sells out for good, change the default to one you have. And when you check a product that “won’t let people buy”, open its page in a private window with no URL parameters, so you see what a new visitor sees. If the dropdowns themselves misbehave, our guide to WooCommerce variations not showing works through the other causes.

One more detail: on products with more than 30 variations, WooCommerce stops sending the full list of variations with the page and looks each choice up as it is made (the limit can be changed with a filter). Defaults still work, but combinations that don’t exist are no longer greyed out in the dropdowns, so a shopper only learns a combination is unavailable after choosing it.

Setting defaults on many products at once#

There is no bulk action for default variations in the product list, but WooCommerce’s own CSV export and import handle them:

  1. Go to Products → Export and export the variable products. Each attribute comes out as a set of columns: Attribute 1 name, Attribute 1 value(s), and, where a default is set, Attribute 1 default.
  2. Fill in the default column for each parent product row, using the value as it appears in the value column, such as Blue. Leave variation rows alone. If no product had a default yet, add the column header yourself in the same pattern.
  3. Import the file under Products → Import with “Update existing products” ticked, so rows are matched to existing products by ID or SKU rather than created again.

Test on two or three products first, and keep the original export as your way back. The import overwrites any field present in the file, so it is safest to delete every column except ID, SKU and the attribute columns before importing.

Setting a default variation programmatically#

Developers can set defaults with the product object. The keys are attribute slugs and the values are term slugs for global attributes, or the value text for custom ones:

$product = wc_get_product( 123 );
$product->set_default_attributes( array(
    'pa_colour' => 'blue',
    'pa_size'   => 'm',
) );
$product->save();

Passing an empty array removes the defaults. A common use is a nightly task that moves each product’s default to its best-selling in-stock variation, which keeps the dead-end rows in the table above from ever reaching a shopper. WooCommerce has no setting for “always preselect the first variation in stock”; that takes code like this, or a variation swatches plugin that offers it.

Which variation should be the default?#

  • Your best seller, if stock is deep. It is what most visitors want anyway, and its image is usually your best photo.
  • The colour, not the size, for fashion. Preselect the colour the main photo shows and let shoppers choose their size; it avoids returns from people who didn’t notice a preselected M.
  • The cheapest option, with care. It makes the price on the page look lowest, but if the cheapest option is rarely bought, it adds a step for everyone else.
  • No default, when the choice really matters. Sizes for rings or replacement parts by model are better left for the shopper to choose deliberately.

Whatever you choose, give the default variation its own image, a SKU and stock, so what the page opens on is complete. Our guides to variation images, variation SKUs and variation stock cover each of those.

Building the variations first with Quick Variable Products#

A default can only point at variations that exist, with a price, stock and image. Creating them one form at a time is the slow part of every variable product, and it is what Quick Variable Products speeds up. The free version on WordPress.org lets you type the attribute values (Red, Blue, Green and S, M, L), generates every combination in one click, and gives each row its own price, SKU and stock, with one image per colour.

The products it creates are ordinary WooCommerce products, so you then set the default in the Variations tab as described above; the plugin itself doesn’t set defaults. Our walkthrough of creating a variable product shows the full process, and the free variation CSV generator builds the same combinations for an import file.

Quick Variable Products: colour and size axes generating a variation grid, with one image per colour
Quick Variable Products (free): generate every colour and size in one go, with one image per colour, then pick the default in WooCommerce.

Quick Variable Products Pro adds the catalogue side: adding variations to products that already exist, and bulk editing prices, stock and other fields across many products with a preview and undo, as in our guide to bulk editing variation prices.

WooCommerce default variation: frequently asked questions#


How do I set a default variation in WooCommerce?

Edit the variable product, open Product data, Variations, and choose a value for each attribute under Default Form Values. Click Update. The product page then opens with that combination selected and its price, stock and image showing. Leave an attribute on No default to keep it unselected.


How do I stop WooCommerce preselecting a variation?

Set every Default Form Values dropdown back to No default and update the product. If a variation is still selected, check the link you used: a URL parameter such as attribute_pa_colour=red selects that value regardless of the product’s default.


Why does my product page say no products matched my selection?

The selected combination is not available. Usually the default points at a variation that is out of stock while Hide out of stock items is on, or at one that is disabled, has no price, or was deleted. Change the default to a variation you can sell.


Can I set default variations in bulk?

Yes, with WooCommerce’s CSV export and import. Export the variable products, fill in the Attribute 1 default column (and further numbers as needed) on each parent row, then import with Update existing products ticked. Test on a few products and keep the original file.


Can a link open a specific variation?

Yes. Add attribute_ and the attribute slug to the product URL, for example ?attribute_pa_colour=red&attribute_pa_size=m for global attributes. The URL value is used before the product’s default, so one product can be linked in several colours.


More in Product Catalog

Keep exploring

All articles
Before you go Let Quick Variable Products do this in WooCommerce

Create product variations, stock, SKUs and prices on one screen. Pro adds bulk editing of existing variations with a preview and undo.

Explore Quick Variable Products Get the free version

Free version on WordPress.org · Pro from $59/year