Title: Custom data to Webhook
Last modified: September 1, 2016

---

# Custom data to Webhook

 *  [andrefc](https://wordpress.org/support/users/andrefc/)
 * (@andrefc)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/custom-data-to-webhook/)
 * Hello!
 * I am trying to send some custom data to my order webhook.
    Basically I am using
   WC Vendors PRO Plugin, so I need to send the vendor address to the webhook.
 * I have followed this other post but it’s not working for me.
    [https://wordpress.org/support/topic/send-custom-data-in-woocommerce-webhook](https://wordpress.org/support/topic/send-custom-data-in-woocommerce-webhook)
 * The $vendor_id is null and nothing is being populated on the json.
 * Here’s my code:
 *     ```
       function my_custom_orders_api_fields($payload) {
   
       $vendor_shop = urldecode( get_query_var( ‘vendor_shop’ ) );
       $vendor_id = get_the_author_meta(‘ID’);
   
       $shop_name = get_user_meta( $vendor_id, ‘pv_shop_name’, true );
   
       $payload[‘loja’][‘nome’] = $shop_name;
   
       return $payload;
       }
   
       add_filter( ‘woocommerce_api_order_response’, ‘my_custom_orders_api_fields’, 10, 2 );
       ```
   
 * Any ideas?
    thank you!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [bnoleite](https://wordpress.org/support/users/bnoleite/)
 * (@bnoleite)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/custom-data-to-webhook/#post-7715331)
 * Hello Andre,
 * If you can query the product ID, then query the post_author for the products 
   post ID. That’s the vendor. From there, the world is yours!
 *     ```
       function my_custom_orders_api_fields($payload) {
   
       $post = $order->id;
   
       $items = $order->get_items();
       foreach ( $items as $item ) {
       $product_id = $item['product_id'];
       }
   
       $vendor_id = get_post_field( 'post_author', $product_id );
   
       $shop_name = get_user_meta( $vendor_id, ‘pv_shop_name’, true );
   
       $payload[‘loja’][‘nome’] = $shop_name;
   
       return $payload;
       }
   
       add_filter( ‘woocommerce_api_order_response’, ‘my_custom_orders_api_fields’,
       ```
   
 *  Thread Starter [andrefc](https://wordpress.org/support/users/andrefc/)
 * (@andrefc)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/custom-data-to-webhook/#post-7715334)
 * Awesome thank you bnoleite!
    I will give it a try!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Custom data to Webhook’ is closed to new replies.

## Tags

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

 * 2 replies
 * 2 participants
 * Last reply from: [andrefc](https://wordpress.org/support/users/andrefc/)
 * Last activity: [9 years, 9 months ago](https://wordpress.org/support/topic/custom-data-to-webhook/#post-7715334)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
