Q:

I need to add a custom function to post data to woocommerce's checkout process

I have been asked by the owner of a woocommerce/wordpress site to add a function into the checkout process that's kicked off when a user clicks "place order", but I'm not entirely sure how to go about getting this function to go off once the order is placed.  The reason for their request is that this particular customer wants their supplier to be automatically notified of any orders, as well as their staff.  
What the function does (or is supposed to do) is take the information from the checkout form, and pass it to a SOAP API used by the supplier's system. 
Here's the code:
<? php

$request = new HttpRequest();
$request->setUrl($PRIVATE);
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'Postman-Token' => $private_key,
  'cache-control' => 'no-cache',
  'SOAPAction' => $private_url,
  'Content-Type' => 'text/xml'
));

$request->setBody('<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   //This part doesn't actually matter - is specific to the supplier's system and I've removed it for privacy. 
   </soapenv:Body>
</soapenv:Envelope>');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
? >

The major issue here is that there is no staging site (and I don't have the ability to create one), so I need to implement this on a live site, and I'm not confident that this will not break the checkout process, or the site at large if I try to use this.  Unfortunately, I haven't found a lot of material detailing how others have handled similar implementations in my searching - most of what I see is "use a plug-in that won't solve your issue", or something to that effect. 
That said, I really need to understand what's going on so that I can get this project back into the client's hands.  Thank you in advance for your time and assistance! 

A:

I've done similiar implementations in the past.  I add it to the woocommerce_thankyou hook. 
add_action('woocommerce_thankyou', 'send_order');

function send_order($order_id){
    $order = wc_get_order( $order_id );

    /*** Your code ***/

}

