How to setup a bulk action in the woocommerce order list

41
January 14, 2022, at 9:00 PM

I am working on some new code for my website but sadly I hit a roadblock. Using the following question I was able to setup some code in preparation for my other functionalities.

Add custom bulk actions to admin orders list in Woocommerce 3

I wrote the following:

<?php    
add_filter( 'bulk_actions-edit-shop_order', 'doa_bulk_actions_collect_products', 20, 1 );
function doa_bulk_actions_collect_products( $actions ) {
    $actions['doa-collect-orders'] = __( 'Verzamel producten', 'woocommerce' );
    return $actions;
}
add_filter( 'handle_bulk_actions-edit-shop_order', 'doa_handle_bulk_action_collect_products', 10, 3 );
function doa_handle_bulk_action_collect_products( $redirect_to, $action, $post_ids ) {
    if ( $action !== 'doa-collect-orders' ) {
        return $redirect_to;
    }
    return $redirect_to = add_query_arg( array( 'doa_collect_orders' => 'thisisatest' ), $redirect_to );
}
?>

According to my knowledge this should work fine. But when I use the action I get a white page. On the following URL:

wp-admin/edit.php?s=&post_status=all&post_type=shop_order&_wpnonce=cb753a3863&_wp_http_referer=%2Fwp-admin%2Fedit.php%3Fpost_type%3Dshop_order&action=doa-collect-orders&m=0&deliveryDate=&_customer_user=&paged=1&post%5B%5D=204576&action2=doa-collect-orders

I can see the action is preformed but the argument doesn't seem to be added. Am I missing something completely? I have tried soo many changes but nothing seems to get it to work. Any help would be greatly apreciated!

READ ALSO
Spring webclient is not logging error response and performing consumer action on receiving error

Spring webclient is not logging error response and performing consumer action on receiving error

I have a spring boot service where APIs are exposed via RouterFunctionOnce the API request is received , certain validations are triggered

53
How to make a website that makes websites [closed]

How to make a website that makes websites [closed]

Want to improve this question? Update the question so it focuses on one problem only by editing this post

51
Android Room database - Delete rows after row limit?

Android Room database - Delete rows after row limit?

I'm trying to delete any inactive rows after a limit of 1000 rows, and I've tried this:

64
Unload javascript file when modal dialog is closed

Unload javascript file when modal dialog is closed

I have a modal dialog that has been styled to show along the right hand side of the customers browserDepending on the icon they click in a nav bar (here is an example)

30