Automattic\WooCommerce\StoreApi\Schemas\V1
CartItemSchema::get_item_data
Format cart item data removing any HTML tag.
Метод класса: CartItemSchema{}
Хуки из метода
Возвращает
Массив.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_item_data( $cart_item );
- $cart_item(массив) (обязательный)
- Cart item array.
Код CartItemSchema::get_item_data() CartItemSchema::get item data WC 10.5.0
protected function get_item_data( $cart_item ) {
/**
* Filters cart item data.
*
* Filters the variation option name for custom option slugs.
*
* @since 4.3.0
*
* @internal Matches filter name in WooCommerce core.
*
* @param array $item_data Cart item data. Empty by default.
* @param array $cart_item Cart item array.
* @return array
*/
$item_data = apply_filters( 'woocommerce_get_item_data', array(), $cart_item );
$clean_item_data = [];
foreach ( $item_data as $data ) {
// We will check each piece of data in the item data element to ensure it is scalar. Extensions could add arrays
// to this, which would cause a fatal in wp_strip_all_tags. If it is not scalar, we will return an empty array,
// which will be filtered out in get_item_data (after this function has run).
foreach ( $data as $data_value ) {
if ( ! is_scalar( $data_value ) ) {
continue 2;
}
}
$clean_item_data[] = $this->format_item_data_element( $data );
}
return $clean_item_data;
}