Skip to content

Instantly share code, notes, and snippets.

@scottopolis
Last active June 20, 2022 14:47
Show Gist options
  • Save scottopolis/1fa6400ddf0be63b40d3caa9985d3646 to your computer and use it in GitHub Desktop.
Save scottopolis/1fa6400ddf0be63b40d3caa9985d3646 to your computer and use it in GitHub Desktop.
Modify WooCommerce REST API Product Response
<?php
// add this code to a custom plugin
add_filter( 'woocommerce_rest_prepare_product_object', 'wc_app_add_custom_data_to_product', 10, 3 );
// filter the product response here
function wc_app_add_custom_data_to_product( $response, $post, $request ) {
// in this case we want to display the short description, so we copy it over to the description, which shows up in the app
$response->data['description'] = $response->data['short_description'];
return $response;
}
@matthewfarlymn
Copy link

@naumanahmed19 it looks like the correct filter now includes object woocommerce_rest_prepare_product_object http://hookr.io/actions/woocommerce_rest_prepare_product_object/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment