I would like to add some custom data to the end of the preview order in Woocommerce order listing page.
For that I have tried the hook 'woocommerce_admin_order_preview_end'. But no way to pass any arguments to that action.
add_action( 'woocommerce_admin_order_preview_end', 'custom_display_order_data_in_admin' );
function custom_display_order_data_in_admin( $order ){
//$order is empty here
}
Does anybody have an idea on this? I'm stuck on this.
You can't get the order object as it's a template that loads specific data via Ajax and there is no arguments for
woocommerce_admin_order_preview_end
action hook.Instead the filter hook
woocommerce_admin_order_preview_get_order_details
will allow you first to add some custom data that you will be able to call and display it after inwoocommerce_admin_order_preview_end
action hook.The code:
Code goes in function.php file of your active child theme (or active theme). Tested and works.