On the orders page in woo-commerce I added a button in the actions row, by click this button i want to make curl call to a web service, the code work well when I hook so_payment_complete function, but my goal now would be to make the call by clicking the button i added on orders page. Any suggestion?
You can use JavaScript code for make an ajax request to your PHP function through wordpress hook wp_ajax and wp_ajax_nopriv.
This is and example
JavaScript code:
$( "#button" ).on( "click", function(e) {
e.preventDefault();
$n.ajax({
type: "POST",
url: '<?php echo admin_url('admin-ajax.php'); ?>',
data: YOUR DATA,
async:true,
success: function(msg){
}
});
});
PHP code:
add_action( 'wp_ajax_action', 'FUNCTION_NAME' );
add_action( 'wp_ajax_nopriv_action', 'FUNCTION_NAME' );
function FUNCTION_NAME() {
//YOUR CURL
}
Let me know.