I would like to trigger an action hook (or something similar) on specific order status change. The code should be run only once from order status "processing" to "completed".
Here is m code attempt:
function payment_complete( $order_id, $old_status, $new_status ){
if( $new_status == "completed" && $old_status == "processing") {
// $this->generate_order_file($order_id);
echo '<script>alert("Working now, but not once:()")</script>';
}
}
add_action( 'woocommerce_order_status_changed', 'payment_complete', 99, 3 );
But it seems that my code runs multiple times. I am stuck for instance. Any help will be appreciated.