How to find a WooCommerce product meta key and bulk edit plugin fields
To bulk edit a field that another plugin or your theme added to WooCommerce products, BEAR needs the field's meta key: the name under which WordPress stores the value in the wp_postmeta table. The label on the product screen is not the key, and neither is the id of the input you see in the browser inspector. Once you have the key, you attach it in the Meta Fields tab and the field becomes a column like any other. Below are four ways to find a WooCommerce product meta key, how to pick the right view for it, why variations may need a second key, and how to recognise fields that are not meta at all.
How to find a WooCommerce product meta key
1. Ask BEAR for the keys of one product
- Open a product, fill in the field with a value you will recognise, for example
TEST-777, and press Update. Many plugins store nothing until a field has a value, so an untouched product may not have the key yet. - Note the product ID: it is in the ID column of BEAR and in the edit screen address (
post=123). - In the Meta Fields tab, enter the ID in Get meta keys from any product by its ID and press Get. Every meta key of that product is added to the list, except WooCommerce's own keys such as price, SKU, stock and images, which are built-in columns.
- Look for the plugin's prefix in the names. If several keys could be the one, keep them all for now, press Save meta fields, switch the columns on in the Settings tab, and see which column shows
TEST-777. Then delete the other rows in the Meta Fields tab.
Keys that start with an underscore are normal: WordPress hides such keys from its own Custom Fields box, and many plugins use them on purpose. ACF is a special case with a pair of keys, name and _name; the article on bulk editing ACF fields explains which one to use. If no new key appears after you filled in the field, the value is not stored as product meta; see the section on fields that are not meta below.
2. Read the field's name in the product form
Right-click the field on the product edit screen and choose Inspect. The name attribute of the input is often the meta key, especially for fields built with WooCommerce's own form functions. The id attribute is not reliable: an id such as location_0 is a form element, and attaching it in BEAR gives an empty column. Names with brackets, such as variable_custom_note[0] or quantity_rules[0][max], describe the form, not the database: [0] is the row of a variation and [max] a part of an array. Use the name only as a hint and confirm it with method 1.
3. Look in the database
With phpMyAdmin or Adminer from the hosting panel, this read-only query lists every key and value of one product (replace wp_ if $table_prefix in wp-config.php says otherwise, and 123 with the product ID):
SELECT meta_key, meta_value FROM wp_postmeta WHERE post_id = 123;
With WP-CLI, wp post meta list 123 prints the same. Unlike method 1, both show the values, which tells you how the data is stored.
4. Ask the plugin's author
The documentation or support of the plugin that owns the field can name the key and the format. Ask both questions: which key, and what does a stored value look like.
Choose the view from the stored value
BEAR writes exactly what you give it, so the view and type in the Meta Fields tab must match what the owning plugin stores.
| The stored value looks like | View and type in BEAR |
|---|---|
| Text, a code, a URL | textinput, string |
A price or quantity, such as 12.50 | textinput, number (sorting, from/to filter, increase by %) |
1 or 0 | checkbox; for yes/no see checkbox custom fields |
| Long text or HTML | textarea |
A ten-digit number such as 1767225600 (a Unix timestamp) | calendar |
a:2:{i:0;s:3:"red";...} (a serialized PHP array) | array, see serialized meta data |
| A serialized list of image IDs | gallery, see variation images and galleries |
JSON text, such as {"min":1,"max":5} | textinput or textarea, edited with care: the array view saves a PHP array, which is not the format the plugin wrote |
If a value holds several settings in one array, attach the base key with the array view, not a key with brackets. The Meta Fields documentation describes the tab itself.
Variations may use a different key
A plugin can store the same setting under one key on simple products and under another key on variations, for example a custom stock text kept in one key for products and a second key for variations. Editing the first key on variations then changes nothing that the plugin reads. Switch on variations on the tools panel, copy a variation ID from the ID column and run Get meta keys from any product by its ID with it. Attach the variation key as well, and edit it with the variations switch on. The text and number rows of the Bulk Edit tab then write to the variations; meta field filters look at the parent products, so select variations by their attributes, as in filtering variations by attribute.
Fields that are not product meta
- Taxonomies. A field that offers a list of terms with checkboxes, like brands or some feed categories, is usually a taxonomy. BEAR shows product taxonomies in the column list of the Settings tab, as described in custom taxonomies. Some plugins register a taxonomy but keep their real data in meta; if changing the taxonomy column has no effect, look for a meta key.
- Custom tables. Some plugins keep product data in tables of their own. No meta key reaches it, so the field must be edited with that plugin's screens, as with the purchase price of ATUM in bulk editing cost of goods.
- Settings and calculated values. A value set once for the whole shop or a category lives in the options, and some values are calculated on every page view. Neither belongs to a product.
Values the other plugin changes back
BEAR saves a meta value and then runs save_post, save_post_product, edit_post and woocommerce_update_product (woocommerce_update_product_variation for a variation), the notifications WordPress and WooCommerce send when a product is saved. It does not submit the product edit form. Two kinds of plugins react to that differently from a manual save:
- Plugins that do extra work only when the form is submitted, for example creating attachment records or recalculating a schedule, do not run. The meta is saved, but the plugin's other data is not created, and the field seems to have no effect until someone presses Update on the product.
- Plugins that check their data whenever a product is saved can override the value by their own rules: a pre-order or delivery date plugin may reset a flag, or clear a date that has no matching status.
To find out what the plugin needs, run Get meta keys on a product before and after you change the setting by hand, and compare the keys and values. Often one visible setting is two or three keys that must be set together. If the plugin still resets the value, its author is the one who can say which data it expects.
Numbers instead of names, broken URLs
- A number where you expected a name. A meta column shows the stored value as it is. Many fields store IDs: a category ID (Yoast's primary category
_yoast_wpseo_primary_product_cat), an attachment ID for an image or file, a user ID for a vendor, product IDs for linked products. Edit them by typing the ID. To see category names, use the taxonomy column instead. - A URL that ends up empty or as an array. A text cell reads a percent sign followed by two characters from 0–9 and A–F, as in
%D0%BFor%20, as URL-encoded form data, and the value is not saved as text. Browsers copy addresses with non-Latin letters in that encoded form. Paste the readable address, with the real letters, instead.
Deleting a row in the Meta Fields tab removes only the column from BEAR; the values stay on the products. The key of an attached field cannot be renamed either: a different key is different data, and the old values remain under the old key. To clear a field on many products, see setting an empty value.
Checklist for a new plugin field
- The field was filled on one product and the key was confirmed with Get meta keys from any product by its ID.
- The view and type match the stored value.
- Variations were checked for a key of their own.
- A test edit on one product shows the new value on the product edit screen and on the product page.
If the key or its format is still unclear, post the plugin name and a product ID on the BEAR support forum.