I have customized the bulk edit functionality using
add_action('woocommerce_product_bulk_edit_start', function () {
// ...
}, 10, 0);
add_action('woocommerce_product_bulk_edit_save', function ($product) {
// ...
}, 10, 1);
I would like to do some further processing after all products have been saved. Is there a hook I can tie into for that?
Any pointers are welcome.
Clarification: I do need to access all information sent in the bulk edit request (bulk edit field values, product ids, etc.).
You could use Wordpress admin_init
action hook like in this example, where a custom message is displayed after products have been saved:
add_action( 'admin_init', 'after_bulk_edit_products_save' );
function after_bulk_edit_products_save() {
global $pagenow;
if( $pagenow === 'edit.php' && isset($_GET['post_type']) && $_GET['post_type'] === 'product'
&& isset($_GET['paged']) && ( isset($_GET['updated']) || isset($_GET['skipped']) || isset($_GET['locked']) ) ) {
add_action( 'admin_notices', 'custom_bulk_action_admin_notice' );
}
}
function custom_bulk_action_admin_notice() {
echo '<div id="message" class="updated"><p>This is a custom message displayed after save</p></div>';
}
Code goes in function.php file of your active child theme (active theme). Tested and works.
You can access from
$_GET
the following variables (always useisset()
to avoid errors):
$_GET['post_type']
- the post type which is "product"$_GET['paged']
- default value is "1" most$_GET['updated'
] - the number of products "updated"$_GET['skipped']
- the number of products "skipped"$_GET['locked']
- the number of products "locked"
You have access to all the data submitted for bulk edit (and quick edit) in the
$_REQUEST
global.