Title: Custom Webhook results not in array
Last modified: April 12, 2017

---

# Custom Webhook results not in array

 *  [sueh27](https://wordpress.org/support/users/sueh27/)
 * (@sueh27)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/custom-webhook-results-not-in-array/)
 * I have created an action to send data after an order is completed in WooCommerce.
   I have added the following code to the functionc.php file. I works, but the raw
   data is showing as: billingemail=sub%40imedi.co.za&items%5B90%5D=14-day+Free+
   Trial and I need it as a json array.
 * add_action( ‘woocommerce_order_status_completed’, ‘my_function’ );
    /* * Do something
   after WooCommerce set an order status as completed */ function my_function($order_id){
 *  // order object (optional but handy)
    $order = new WC_Order( $order_id ); $billingEmail
   = $order->billing_email; $products = $order->get_items();
 *  foreach($products as $prod){
    $items[$prod[‘product_id’]] = $prod[‘name’]; }
 *  $url = ‘[http://requestb.in/15k6boy1&#8217](http://requestb.in/15k6boy1&#8217);;
 *  // do some stuff here
 * wp_remote_post( $url, array(
    ‘method’ => ‘POST’, ‘timeout’ => 45, ‘redirection’
   => 5, ‘httpversion’ => ‘1.0’, ‘blocking’ => true, ‘headers’ => array(), ‘body’
   => array( ‘billingemail’ => $billingEmail, ‘items’ => $items ), ‘cookies’ => 
   array() ) ); }

Viewing 1 replies (of 1 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/custom-webhook-results-not-in-array/#post-9023644)
 * `'body' => json_encode( array( 'billingemail' => $billingEmail, 'items' => $items)),`
 * Next time you post code please use backticks or the code button. Failure to do
   so makes copy/pasting any part of your code difficult because all the quotes 
   are wrong 😉

Viewing 1 replies (of 1 total)

 The topic ‘Custom Webhook results not in array’ is closed to new replies.

## Tags

 * [function.php](https://wordpress.org/support/topic-tag/function-php/)
 * [webhook](https://wordpress.org/support/topic-tag/webhook/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [9 years, 6 months ago](https://wordpress.org/support/topic/custom-webhook-results-not-in-array/#post-9023644)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
