WooCommerce filter variations by attribute and bulk edit only those
You filter WooCommerce products by Size = XL, switch on variations, and the table lists S, M, L and XL of every product. To filter variations by attribute and change only the XL ones, for example their price, stock or weight, you need a second step. The filter chooses products; the variations inside them are chosen in the Bulk Edit tab, by hand, or in Variations Advanced Bulk Operations. Below is why the filter behaves this way and how to use each method, including deleting variations with a certain value.
Why filtering by an attribute shows all variations
In WooCommerce a global attribute is a taxonomy, and its terms are attached to the parent product: a T-shirt with sizes S to XL carries all four terms. Each variation stores only its own value, in a field of its own (attribute_pa_size = xl), and has no terms. The Filters tab queries products, so Size = XL returns every variable product that has XL among its terms.
The variations switch on the tools panel then lists all variations of every product on the page, matching or not. Filters on fields that variations have themselves (SKU, regular and sale price, stock quantity, weight and dimensions) work differently: they find the parent product and also narrow its variation list, so only the matching variations appear under it. A title search lists all variations, because every variation title contains the title of its parent. Taxonomy and meta field filters, including attributes, look at the parent only.
So the filter is the first half: it narrows the products. Use it to keep the run small, for example product type variable plus the category, plus Size = XL to skip products that have no XL at all. The second half picks the variations.
Method 1: attribute combinations in the Bulk Edit tab
This is the way to change one size across many products, on every page of the filter result at once.
- Filter the products as above and switch on variations on the tools panel. The Bulk Edit tab now says that operations apply to the variations and that parent products are ignored, and it shows the select combination of attributes field.
- In that field select every attribute the variations are built on, for example Size and Color, and press Add attributes combination to apply on. A row of drop-downs appears, one per attribute.
- Set Size to XL and Color to Any.
- Tick the field to change, for example regular price with set new, or weight in the Additional section, enter the value and press Do Bulk Edit.
How a variation is matched against the row decides whether anything changes:
- The row must name exactly the attributes the variation is built on, no more and no fewer. A row with Size alone does not match variations built on Size and Color. Their order does not matter.
- Any matches every value of that attribute. not selected is different: it matches only variations whose value is empty, the ones WooCommerce shows as "Any Size". An attribute left at not selected is the usual reason a run finishes and nothing changes.
- Several rows can be added; a variation changes when it matches one of them. If some products are built on Size only and others on Size and Color, add a row for each set.
- Everything that does not match is skipped, as are parents and simple products.
The same method gives all products with the same sizes the same variation prices: one run per size with set new, S in the first run, M in the second, and so on. The FAQ on variation prices per size shows it with screenshots. Weight per pack size or stock per size work the same way. The run is recorded in History and can be rolled back.
Method 2: tick variation rows and use binded editing
For an irregular set on one page, choose the rows yourself. With the switch on, each variation row shows its attribute values next to the product title, so XL rows are easy to spot.
- Tick the variation rows to change. Hold SHIFT to tick a range; the select all variations button on the tools panel ticks every variation row of the page and none of the parents.
- Switch on binded editing.
- Edit the cell in one of the ticked rows. The value is written to every ticked variation.
The column you edit must be switched on in the Settings tab; weight, length, width and height are off by default. Ticks live on the current page, so raise the products per page for this method, within reason: each product on the page brings all its variations along.
Method 3: delete, disable or rename variations with a certain value
Changing the structure of variations is the job of the Variations Advanced Bulk Operations button on the tools panel, described in the variable products documentation. These operations are not recorded in History, so make a database backup first.
- Delete by combination. In the Deleting tab select all attributes of the variations, choose Delete the products variations according to the combination of the attributes, set the terms and press Start deleting. The match is exact: every attribute must be given and there is no Any, so one run deletes one combination. Removing XL in five colours takes five runs. The deletion is permanent. To remove every variation instead, see removing all variations at once.
- Delete by ticking. For a page of products it is faster to tick the XL rows as in Method 2 and press the delete button on the tools panel. Deleted rows go to the trash.
- Disable instead of delete. If the variations may come back, use Method 1 with Size = XL, Color = Any and set the post status to Private. Private variations are disabled in WooCommerce and cannot be bought, and the run can be rolled back in History. The FAQ on enabling and disabling variations has the details.
- Change the value. To turn every XL into 2XL without recreating the variations and losing their prices, use the Swap operation from the swap FAQ.
Limits: custom attributes, variation meta fields, huge products
Only global attributes. The combination selector, the Filters tab and Variations Advanced Bulk Operations list the attributes created under Products, Attributes. An attribute typed directly on a product (a custom product attribute) is plain text stored on that product; it is not a taxonomy and cannot be filtered or matched. If the combination selector says no attributes exist, or your Size is missing from it, it is such a text attribute. Recreate it as a global attribute and attach it to the products before using any method above.
Custom fields on variations. Meta fields attached in the Meta Fields tab are editable on variations, but the meta field filter looks at the parent products. Select variations by their attributes, not by a meta value.
Products with hundreds or thousands of variations. Every product on the page brings all of its variations into the table, and a bulk run processes all variations of each product in its batch. Lower the products per page to 10 or 5 before switching variations on, and if runs end with a timeout, lower Number of posts processed at a time in the Settings tab. More in bulk editing thousands of products.
If the run changed nothing
- Check that the variations switch was on when you pressed Do Bulk Edit; without it the run goes to parents, which hold no variation data.
- Check the combination row: every attribute of the variation selected, no attribute left at not selected unless you mean "Any" variations.
- Compare the attribute in the row with the one on the product: a global Size and a typed-in Size look the same on the product page but only the global one can match.
- Read the line at the top of the Bulk Edit tab: ticked products take priority over the filter, and a forgotten tick limits the run to one product.
For a setup that still does not match, post the attributes of one product and the combination you used on the BEAR support forum.