'add custom metadata to woocommerce webhook hook
I have a webhook set up to trigger when there is a new order and it works just fine, I use it in a custom app to notify when there is a new order. But now i need to be able to add custom meta data to the webhook, is this possible?
the current output
{
"id": 1,
"name": "alert new order",
"status": "active",
"topic": "order.created",
"resource": "order",
"event": "created",
"hooks": [
"woocommerce_new_order"
],
is there a way to add meta data in this hooks array or in the same json like
{
"id": 1,
"name": "alert new order",
"status": "active",
"topic": "order.created",
"resource": "order",
"event": "created",
"metdadata": "mata data value"
"hooks": [
"woocommerce_new_order"
],
The php (found it searching around)so far i had tried but simple does not work or do anything
add_action( 'woocommerce_webhook_payload', 'sendsikkert_woocommerce_webhook_payload' );
function sendsikkert_woocommerce_webhook_payload( $payload, $resource, $resource_id, $id ) {
$order = wc_get_order( $resource_id );
$ssmail = get_post_meta( $order->get_order_number(), '_token', true );
$cvrnr = get_post_meta( $order->get_order_number(), 'restaurante', true );
$payload['order']['Sendsikkert_email'] = $ssmail;
$payload['order']['CVRNR'] = $cvrnr;
return $payload;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
