BEAR - WooCommerce Bulk Editor and Products Manager Professional

Bulk edit checkbox custom fields in WooCommerce without wrong values

When you bulk edit a checkbox custom field of WooCommerce products, the value BEAR writes must be the value the owning plugin reads. A checkbox has no single standard: one plugin stores 1 and 0, another yes and no, a third on or nothing. If they do not match, the field looks inverted: ticked in the product editor but off in BEAR, and switched off on the product the moment you switch it on in BEAR. The same applies to select fields, which store a value the editor never shows. Below is how each format is stored, how to make BEAR write exactly that format, and which tool to use for a bulk run.

How plugins store a checkbox

Where the checkbox comes fromTickedNot ticked
WooCommerce's woocommerce_wp_checkbox() form function, used by many plugins and themesyesno or empty, depending on the plugin's save code
ACF True / False and many custom plugins10
A plain HTML checkbox saved as it is sentonempty or no key
Some pluginstruefalse

To see which one a field uses, tick it on one product, save, and read the stored value: attach the key as a textinput field for a moment, or look it up as described in finding a product meta key. Germanized's _unit_price_auto, the switch that turns on automatic unit price calculation, is one that stores yes and no.

Why the field looks inverted in BEAR

A meta field with the checkbox view writes 1 when switched on and 0 when switched off, and shows a cell as on only when the stored value is 1. For a field that stores yes:

  • A product with the box ticked in WooCommerce shows as off in BEAR, because yes is not 1.
  • Switching it on in BEAR writes 1. The plugin checks for yes, so the box is now unticked in the product editor.
  • Switching it off writes 0, which is also not yes.

Nothing is broken in either plugin: they speak different values. The fix is to tell BEAR which values this key uses.

Bulk edit checkbox custom fields with your own values

In the Settings tab, under General settings, fill in Override meta checkbox value. Each rule is the meta key, a colon, the value for on, a caret and the value for off:

_unit_price_auto:yes^no,_hide_in_feed:yes^no,_show_badge:on^
  • Separate rules with commas and do not put spaces after them: the key must match exactly, and _hide_in_feed with a leading space is a different key.
  • Always give both values. With only the first, as in _show_badge:on, switching off still writes 0. To store an empty value for off, end the rule with the caret, as _show_badge:on^ above.
  • A cell is shown as on when the stored value equals the first value exactly. Yes with a capital letter is not yes.

Save the settings and reload the editor. The column now shows the real state, and switching a cell writes the plugin's values. With binded editing on, the same switch goes to every ticked product, as long as Load beauty switchers in the same settings stays at its default, Yes. The Settings documentation lists the other options of that block.

Bulk runs on the whole catalogue: use a text field

For a checkbox field, the Bulk Edit tab offers a drop-down in the statuses and types group, and the Filters tab offers a Yes/No filter. Both are limited:

  • The Bulk Edit tab's Yes writes 1, or the first override value. Its No does not write 0 or the second override value in the current version: it saves 2, which a 1/0 field treats as on and a yes/no field does not recognise.
  • The Yes/No filter compares with 1 and 0 and ignores the override, so it cannot find products by yes or no.
  • With the variations switch on, checkbox fields are not offered in the Bulk Edit tab at all.

For catalogue-wide work, switch the field's view to text for the time of the run. The view only tells BEAR how to show and write the field; changing it does not touch the stored values.

  1. In the Meta Fields tab, set the field's view to textinput and its type to string, and press Save meta fields. The column now shows the raw values: yes, no, 1, 0, or nothing.
  2. In the Filters tab, find the products to change with the field's text filter: behaviour EXACT (=) with yes, or Empty for products that never had the field saved. A filter for 2 finds products touched by an earlier No run.
  3. In the Bulk Edit tab, tick the field's row in the text group, type the exact value, such as no, choose new and press Do Bulk Edit. With the variations switch on, this row also writes to variations.
  4. Set the view back to checkbox if you prefer switches for everyday edits.

Many shops simply keep yes/no fields as text fields. Every bulk run is recorded in History and can be reverted.

Select and dropdown fields

A select field stores the value of the chosen option, which is often not the label the editor shows: the label Large box may be stored as box_l. BEAR cannot offer the plugin's list of options for a meta field, because a meta field is free data and the list exists only in the other plugin's code. Attach such a field as textinput and string and type the stored value:

  1. On a test product, choose each option in turn, save, and note the value the column shows. That is the list of valid values.
  2. Use the text filter with EXACT (=) to find products with one option, and the Bulk Edit tab with new to set another.

A value that is not on the plugin's list is saved, but the plugin will not recognise it; its select usually shows the first option, and the front end may ignore the field. Germanized's _unit is such a field: it holds one unit as text, and BEAR edits it as text rather than as a drop-down of units. Multi-select fields store a serialized list; for ACF, see bulk editing ACF fields, and for other plugins the array view described in the Meta Fields documentation.

Textarea fields

The textarea view stores text like the string type and edits it in a popup with the WordPress editor, which suits long texts and HTML. In its visual mode, the editor wraps plain text in paragraph tags; for a field that must stay plain, such as a code or a short note printed inside another sentence, switch the popup to its text mode before saving, or use textinput. A textarea field has the same text filter and Bulk Edit row as a textinput field.

Whatever the view, attach the key exactly as stored, preferably from Get meta keys from any product by its ID. The key of an attached field cannot be renamed: a different key is different data, and values saved under a mistyped key stay there until you remove them.

Checklist

  • The stored values of the field are known: 1/0, yes/no, on/empty, or something else.
  • Fields that do not store 1/0 have an Override meta checkbox value rule with both values and no spaces.
  • Bulk runs and filters use the text view with the exact value.
  • Select fields are edited with the option value, not its label.
  • After a test on two products, the product editor shows the box ticked or unticked as expected.

If a field stores something not covered here, post the field's key and a product ID on the BEAR support forum.