WordPress at Your Fingertips
function is not described

WC_REST_Order_Refunds_V2_Controller::get_formatted_item_data() protected WC 3.0.0

Get formatted item data.

{} It's a method of the class: WC_REST_Order_Refunds_V2_Controller{}

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_formatted_item_data( $object );
$object(WC_Data) (required)
WC_Data instance.

Changelog

Since 3.0.0 Introduced.

Code of WC_REST_Order_Refunds_V2_Controller::get_formatted_item_data() WC 5.9.0

protected function get_formatted_item_data( $object ) {
	$data              = $object->get_data();
	$format_decimal    = array( 'amount' );
	$format_date       = array( 'date_created' );
	$format_line_items = array( 'line_items', 'shipping_lines', 'tax_lines', 'fee_lines' );

	// Format decimal values.
	foreach ( $format_decimal as $key ) {
		$data[ $key ] = wc_format_decimal( $data[ $key ], $this->request['dp'] );
	}

	// Format date values.
	foreach ( $format_date as $key ) {
		$datetime              = $data[ $key ];
		$data[ $key ]          = wc_rest_prepare_date_response( $datetime, false );
		$data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime );
	}

	// Format line items.
	foreach ( $format_line_items as $key ) {
		$data[ $key ] = array_values( array_map( array( $this, 'get_order_item_data' ), $data[ $key ] ) );
	}

	return array(
		'id'               => $object->get_id(),
		'date_created'     => $data['date_created'],
		'date_created_gmt' => $data['date_created_gmt'],
		'amount'           => $data['amount'],
		'reason'           => $data['reason'],
		'refunded_by'      => $data['refunded_by'],
		'refunded_payment' => $data['refunded_payment'],
		'meta_data'        => $data['meta_data'],
		'line_items'       => $data['line_items'],
		'shipping_lines'   => $data['shipping_lines'],
		'tax_lines'        => $data['tax_lines'],
		'fee_lines'        => $data['fee_lines'],
	);
}