How to change Webhook’s response in Woocommerce?

Asked

Viewed 73 times

0

I have a problem in Woocommerce REST_API, in case the endpoint response wp-json/wc/v2/Orders, in products(line_items) is not returned metadata(metadata of products).

inserir a descrição da imagem aqui

As in the image above, it can be observed that the values for the metadata, are empty!

I solved that question using register_rest_field, this is the code of the solution below!

inserir a descrição da imagem aqui

The solution adds to key products in the REST_API response, within this array has the product id along with the metadata that I need!

inserir a descrição da imagem aqui

The problem is that I want this change to be applied to Webhook, I thought by changing the REST_API endpoint response, it would also change the Webhook response. But this script has no effect on Webhook.

Can someone help me solve this problem?

1 answer

0


I was able to solve my problem using the filter

*woocommerce_rest_prepare_{$post_type}_object*!

That was the solution: inserir a descrição da imagem aqui

  • Avoid using code images. To respond copy your code and use the answer field tools to paste it here in the correct way.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.