I want to add a new button for other actions beside the refund button in Edit Order page for WooCommerce.
I know it may be possible by hooks, but I can't seem to find the right hook to execute for it.
I want to add a new button for other actions beside the refund button in Edit Order page for WooCommerce.
I know it may be possible by hooks, but I can't seem to find the right hook to execute for it.
Use the following (where you will replace "custom" by your desired action slug and name):
add_action( 'woocommerce_order_item_add_action_buttons', 'wc_order_item_add_action_buttons_callback', 10, 1 );
function wc_order_item_add_action_buttons_callback( $order ) {
$label = esc_html__( 'Custom', 'woocommerce' );
$slug = 'custom';
?>
<button type="button" class="button <?php echo $slug; ?>-items"><?php echo $label; ?></button>
<?php
}
The hook is located in includes/admin/meta-boxes/views/html-order-items.php (line 288)
Then you will have to enable Ajax for this button, adding some jQuery code (sender) and some PHP code (WordPress Admin Ajax receiver), just like for WC_Ajax refund_line_items()…