Home » WooCommerce: Add Custom Field to “Bulk Actions” > “Edit”

WooCommerce: Add Custom Field to “Bulk Actions” > “Edit”

by Tutor Aspire

As you know, one of the product bulk edit methods comes with WooCommerce out of the box. It can be found under “WP Dashboard” > “Products” > “Bulk Actions” > “Edit”. For example, you can decrease all prices by 10%, or bulk assign a new product category.

However, if you added a custom product field such as RRP, this won’t show automatically there in the bulk edit form – you’ll therefore need to add it via code. Thankfully, WooCommerce gives us a “hook” we can use to display the input in the bulk edit form. After that, another PHP function will be used to save and store the value.

Easy as pie! Just copy & paste into your functions.php. Enjoy 🙂

Display a custom product field input inside the “Bulk Edit” window @ WooCommerce Products admin

PHP Snippet: Display a Custom Product Field Input @ WordPress Admin > Products > Bulk Edit

 * @snippet       Custom field bulk edit - WooCommerce
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 4.0
 * @donate $9     https://tutoraspire.com

// Note: change all occurrences of "custom_field" with the key of your custom field

add_action( 'woocommerce_product_bulk_edit_start', 'tutoraspire_custom_field_bulk_edit_input' );
function tutoraspire_custom_field_bulk_edit_input() {
get_id(); if ( isset( $_REQUEST['custom_field'] ) ) { $custom_field = $_REQUEST['custom_field']; update_post_meta( $post_id, 'custom_field', wc_clean( $custom_field ) ); } }

You may also like