Reputation: 227
I have a store working with woocommerce plugin for wordpress and everytime a customer purchase something I record that sale in an internal software I'm using to track my shipments and inventory. To do this I'm using the webkooks feature of woocommerce and everything works fine, but now, I want to send some custom data in the webhook request. I have tried using "custom fields" or "product attributes" in my product but neither those fields are sent by the webhook request. So my question is, is there a way I can send aditional data in the webhook?
Thanks in advance.
Upvotes: 2
Views: 4220
Reputation: 227
I got it working, I used the following code to achieved it:
function add_order_item_meta($item_id, $values) {
$key = 'an_identifier';
$value = get_post_meta( $values['product_id'], 'custom_field_name', true );
woocommerce_add_order_item_meta($item_id, $key, $value);
}
add_action('woocommerce_add_order_item_meta', 'add_order_item_meta', 10, 2);
Upvotes: 4