php - How can i fire my javascript function when woocommerce order has been completed -
i have tested functions, script loaded website , have tested alert on scroll , works cant seem fire function calls web service when woocommerce order being processed using following:
add_action( 'woocommerce_order_status_processing', 'addmy_script', 10, 1 );
im not sure @ moment, how can fire callapi function using hook displayed above?
full code reference:
register script:
function load_javascript() { wp_enqueue_script('prefix_script_01', plugins_url('/wp_callapi.js', __file__), array('jquery')); } add_action('wp_enqueue_scripts', 'load_javascript'); //add_action( 'wp_enqueue_scripts', 'addmy_script' ); function addmy_script() { wp_enqueue_scripts('wp_callapi'); add_action('init', 'callapi'); } add_action('woocommerce_order_status_processing', 'addmy_script', 10, 1);
javascript callapi()
function
jquery(document).ready(function() { callapi(); }); function callapi() { try { jquery(function($) { jquery.ajax({ url: "http://test.com/wsmain.asmx/myfunction", data: data, datatype: "json", type: "post", success: function(msg) { alert(msg + "event has fierd"); } }); }) } catch (e) { alert("error" + e); } }
Comments
Post a Comment