In Woocommerce Admin orders list, when clicking the icon \"eye\" , it opens a preview of the order in a Lightbox. At the bottom of that Lightbox (preview), there are some ac
The correct hook to get this done is woocommerce_admin_order_preview_actions
filter hook.
You will need to define in the function below in a multidimensional array your custom order statuses data, one by one as follow, to get an action button for each:
The example code (here for 2 custom fake statuses "Custom One" and "Custom two"):
add_filter( 'woocommerce_admin_order_preview_actions', 'additional_admin_order_preview_buttons_actions', 25, 2 );
function additional_admin_order_preview_buttons_actions( $actions, $order ){
// Below set your custom order statuses (key / label / allowed statuses) that needs a button
$custom_statuses = array(
'custom_one' => array( // The key (slug without "wc-")
'label' => __("Custom One", "woocommerce"), // Label name
'allowed' => array( 'pending', 'on-hold', 'processing', 'custom_two' ), // Button displayed for this statuses (slugs without "wc-")
),
'custom_two' => array( // The key (slug without "wc-")
'label' => __("Custom Two", "woocommerce"), // Label name
'allowed' => array( 'pending', 'on-hold', 'processing', 'custom_one' ), // Button displayed for this statuses (slugs without "wc-")
),
);
// Loop through your custom orders Statuses
foreach ( $custom_statuses as $status_slug => $values ){
if ( $order->has_status( $values['allowed'] ) ) {
$actions['status']['actions'][$status_slug] = array(
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status='.$status_slug.'&order_id=' . $order->get_id() ), 'woocommerce-mark-order-status' ),
'name' => $values['label'],
'title' => __( 'Change order status to', 'woocommerce' ) . ' ' . strtolower($values['label']),
'action' => $status_slug,
);
}
}
return $actions;
}
Code goes in function.php file of your active child theme (active theme). Tested and works.