Intercept and modify product data sent to woo API V1
-
I have an application which creates and updates products via the woocommerce API v1.
I am trying to intercept the incoming data and modify it before it is processed by the woo API using woocommerce_rest_prepare_product, but I cannot modify any of the data values.
Code I am using in functions.php:
add_filter( 'woocommerce_rest_prepare_product', 'modify_products_api_data', 90, 2 ); function modify_products_api_data( $response, $post ) { $response->data['name'] = 'modified'; return $response; }
I would expect this to change the post title to “modified” but it doesnt do anything at all.
I have also tried with “woocommerce_rest_prepare_product_object”, however as I understand it because the application is using v1 it should be “woocommerce_rest_prepare_product” which is now deprecated in v2+.
Anyone have any suggestions how I can intercept submitted data and be able to modify it before products are created or updated? So for example to overwrite the name of the product, or amend its description text?
Thanks guys, spent many hours on this already and I’m not getting anywhere.
- The topic ‘Intercept and modify product data sent to woo API V1’ is closed to new replies.