I am trying to execute a JavaScript file for when the order status is changed in the back-end. But it doesn’t seem to work. Below is the code I am currently using. Can anybody tell me what I am doing wrong? When I try to enqueue the script in other places, it does work.
function script_on_order_complete( $order_id ) {
wp_register_script('test', get_template_directory_uri() .'/js/test.js',false);
wp_enqueue_script( 'test');
}
add_action( 'woocommerce_order_status_completed', 'script_on_order_complete', 10, 1 );