Automattic\WooCommerce\StoreApi\Schemas\V1
CartItemSchema::get_item_data()
Format cart item data removing any HTML tag.
Method of the class: CartItemSchema{}
Hooks from the method
Return
Array
.
Usage
// protected - for code of main (parent) or child class $result = $this->get_item_data( $cart_item );
- $cart_item(array) (required)
- Cart item array.
CartItemSchema::get_item_data() CartItemSchema::get item data code WC 9.3.3
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; }