/** * This snippet will add cancel order button to all (not cancelled) orders. */ add_filter( 'woocommerce_admin_order_actions', 'add_cancel_order_actions_button', PHP_INT_MAX, 2 ); function add_cancel_order_actions_button( $actions, $the_order ) { if ( ! $the_order->has_status( array( 'cancelled' ) ) ) { // if order is not cancelled yet... $actions['cancel'] = array( 'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=cancelled&order_id=' . $the_order->id ), 'woocommerce-mark-order-status' ), 'name' => __( 'Cancel', 'woocommerce' ), 'action' => "view cancel", // setting "view" for proper button CSS ); } return $actions; } add_action( 'admin_head', 'add_cancel_order_actions_button_css' ); function add_cancel_order_actions_button_css() { echo ''; }
2 thoughts on “Add custom button to admin's Orders list Actions column in WooCommerce”
Leave a Comment
You must be logged in to post a comment.
E13 is giving Blank box. Can i have another code to shwo X sign. ?
I got it
https://graphemica.com/%E2%9D%8C