title: Sending Order Details From WooCommerce To External System Over API
body: <p>I am trying to send woocommerce order to netsuite via an external api I have written. I am nw to woocommerce and do not fully get how to add this functionality.</p>
  
  <p>I have added the following code to the functions.php file in <strong>public_html/wp-content/themes/reverie-master/</strong></p>
  
  <pre><code>add_action( 'woocommerce_payment_complete'', 'wdm_send_order_to_ext'); 
  function wdm_send_order_to_ext( $order_id ){
  // get order object and order details
  $order = new WC_Order( $order_id ); 
  $email = $order-&gt;billing_email;
  $phone = $order-&gt;billing_phone;
  
  //Create the data object
  $orderData = array(
      'customer_email' =&gt; $email,
      'customer_phone' =&gt; $phone
  );
  
  $apiData = array(
      'caller' =&gt; 'woocommerce',
      'json' =&gt; $orderData,
      'key' =&gt; 'MY_SECRET_KEY'
  );
  
  $jsonData =json_encode($orderData);
  
  $url = "";
  $api_mode = 'sandbox';
  if($api_mode == 'sandbox'){
      // sandbox URL example
      $url = "https://forms.netsuite.com/app/site/hosting/scriptlet.nl?script=XXX&amp;deploy=X&amp;compid=XXXXXXX_SB1&amp;h=XXXXXXXXXXXXXXXX"; 
  }
  else{
      // production URL example
      $url = ""; 
  }
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($jsonData));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  
  $response = curl_exec ($ch);
  
  curl_close ($ch);
  
  // the handle response    
  if (strpos($response,'ERROR') !== false) {
          print_r($response);
  } else {
          // success
  }
  }
  </code></pre>
  
  <p>I have tested the brunt of this code, just the parts that do not concern woocommerce in a different site and I can see the data showing up in NetSuite. However, when I go through my store and place an order, and take payment, I do not see the data come into NetSuite. Do I have this code in the right location? Is there something I am missing?</p>
  
  <p><strong>Update</strong>
  I installed the plugin Code Snippets and added the code there instead. Set it to  Run snippet everywhere. Still no luck.</p>