in Wordpress admin dashboard, when you open woocommerce order page, you will see list of the orders and the columns are (Order, Date, Status, Billing, Shipping, Total, Actions)
I would like to add a new button for Action list and then add this action to send the Email Invoice to the customers which orders are still on-hold.
I have created the column and the button as below, but I have trouble with calling the action button to send the invoice to the customers for each order.
please advice.
add_filter( 'woocommerce_admin_order_actions', 'add_custom_order_status_actions_button', 100, 2 );
function add_custom_order_status_actions_button( $actions, $order ) {
if ( $order->has_status( array( 'on-hold' ) ) ) {
// The key slug defined for your action button
$action_slug = 'invoice';
$status = $_GET['status'];
$order_id = method_exists($the_order, 'get_id') ? $the_order->get_id() : $the_order->id;
// Set the action button
$actions[$action_slug] = array(
'url' => admin_url('post.php?post=' . $post_id . '&action=edit&message=11'),
'name' => __( 'Invoice', 'woocommerce' ),
'action' => $action_slug,
);
}
return $actions;
}
add_action( 'admin_head', 'add_custom_order_status_actions_button_css' );
function add_custom_order_status_actions_button_css() {
$action_slug = "invoice"; // The key slug defined for your action button
echo '<style>.wc-action-button-'.$action_slug.'::after { font-family: woocommerce !important; content: "\e029" !important; }</style>';
}