WC_REST_Products_V2_Controller::remove_related_ids_from_response_data
Remove related_ids from response data for ETag calculation.
The related_ids field contains a random sample of related products, so it should not be used for ETag calculation.
Метод класса: WC_REST_Products_V2_Controller{}
Хуков нет.
Возвращает
Массив. Response data without related_ids.
Использование
// private - только в коде основоного (родительского) класса $result = $this->remove_related_ids_from_response_data( $data ): array;
- $data(массив) (обязательный)
- Response data.
Код WC_REST_Products_V2_Controller::remove_related_ids_from_response_data() WC REST Products V2 Controller::remove related ids from response data WC 10.5.2
private function remove_related_ids_from_response_data( array $data ): array {
// Handle single product response.
if ( isset( $data['related_ids'] ) ) {
unset( $data['related_ids'] );
}
// Handle collection response (array of products).
foreach ( $data as $key => $item ) {
if ( is_array( $item ) && isset( $item['related_ids'] ) ) {
unset( $data[ $key ]['related_ids'] );
}
}
return $data;
}