woocommerce_rest_prepare_(taxonomy) filter-hookWC 1.0

Filter a term item returned from the API.

Allows modification of the term data right before it is returned.

Usage

add_filter( 'woocommerce_rest_prepare_(taxonomy)', 'wp_kama_woocommerce_rest_prepare_taxonomy_filter', 10, 3 );

/**
 * Function for `woocommerce_rest_prepare_(taxonomy)` filter-hook.
 * 
 * @param WP_REST_Response $response The response object.
 * @param object           $item     The original term object.
 * @param WP_REST_Request  $request  Request used to generate the response.
 *
 * @return WP_REST_Response
 */
function wp_kama_woocommerce_rest_prepare_taxonomy_filter( $response, $item, $request ){

	// filter...
	return $response;
}
$response(WP_REST_Response)
The response object.
$item(object)
The original term object.
$request(WP_REST_Request)
Request used to generate the response.

Where the hook is called

WC_REST_Product_Attribute_Terms_V1_Controller::prepare_item_for_response()
woocommerce_rest_prepare_(taxonomy)
WC_REST_Product_Tags_V1_Controller::prepare_item_for_response()
woocommerce_rest_prepare_(taxonomy)
WC_REST_Product_Shipping_Classes_V1_Controller::prepare_item_for_response()
woocommerce_rest_prepare_(taxonomy)
WC_REST_Product_Categories_V1_Controller::prepare_item_for_response()
woocommerce_rest_prepare_(taxonomy)
WC_REST_Product_Categories_Controller::prepare_item_for_response()
woocommerce_rest_prepare_(taxonomy)
WC_REST_Product_Categories_V2_Controller::prepare_item_for_response()
woocommerce_rest_prepare_(taxonomy)
woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-product-attribute-terms-v1-controller.php 166
return apply_filters( "woocommerce_rest_prepare_{$this->taxonomy}", $response, $item, $request );
woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-product-tags-v1-controller.php 79
return apply_filters( "woocommerce_rest_prepare_{$this->taxonomy}", $response, $item, $request );
woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-product-shipping-classes-v1-controller.php 79
return apply_filters( "woocommerce_rest_prepare_{$this->taxonomy}", $response, $item, $request );
woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-product-categories-v1-controller.php 104
return apply_filters( "woocommerce_rest_prepare_{$this->taxonomy}", $response, $item, $request );
woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-product-categories-controller.php 88
return apply_filters( "woocommerce_rest_prepare_{$this->taxonomy}", $response, $item, $request );
woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-product-categories-v2-controller.php 88
return apply_filters( "woocommerce_rest_prepare_{$this->taxonomy}", $response, $item, $request );

Where the hook is used in WooCommerce

woocommerce/src/Admin/API/Init.php 49
add_filter( 'woocommerce_rest_prepare_shop_order_object', array( __CLASS__, 'add_currency_symbol_to_order_response' ) );
woocommerce/src/Admin/Features/PaymentGatewaySuggestions/PaymentGatewaysController.php 21
add_filter( 'woocommerce_rest_prepare_payment_gateway', array( __CLASS__, 'extend_response' ), 10, 3 );
woocommerce/src/Internal/Admin/Onboarding/OnboardingThemes.php 33
add_filter( 'woocommerce_rest_prepare_themes', array( __CLASS__, 'add_uploaded_theme_data' ) );