woocommerce_rest_prepare_data_country filter-hookWC 1.0

Filter the states list for a country returned from the API.

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

Usage

add_filter( 'woocommerce_rest_prepare_data_country', 'wp_kama_woocommerce_rest_prepare_data_country_filter', 10, 3 );

/**
 * Function for `woocommerce_rest_prepare_data_country` filter-hook.
 * 
 * @param WP_REST_Response $response The response object.
 * @param array            $data     The original country's states list.
 * @param WP_REST_Request  $request  Request used to generate the response.
 *
 * @return WP_REST_Response
 */
function wp_kama_woocommerce_rest_prepare_data_country_filter( $response, $data, $request ){

	// filter...
	return $response;
}
$response(WP_REST_Response)
The response object.
$data(array)
The original country's states list.
$request(WP_REST_Request)
Request used to generate the response.

Where the hook is called

WC_REST_Data_Countries_Controller::prepare_item_for_response()
woocommerce_rest_prepare_data_country
woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-data-countries-controller.php 166
return apply_filters( 'woocommerce_rest_prepare_data_country', $response, $item, $request );

Where the hook is used in WooCommerce

Usage not found.