WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Internal

RestApiUtil::adjust_line_items_for_create_refund_request() private WC 1.0

Convert the line items of a refund request to internal format (see adjust_create_refund_request_parameters).

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

No Hooks.

Return

Array. The converted line items.

Usage

$result = RestApiUtil::adjust_line_items_for_create_refund_request( $line_items );
$line_items(array) (required)
The line items to convert.

Code of RestApiUtil::adjust_line_items_for_create_refund_request() WC 5.9.0

private static function adjust_line_items_for_create_refund_request( $line_items ) {
	if ( ! is_array( $line_items ) || empty( $line_items ) || self::is_associative( $line_items ) ) {
		return $line_items;
	}

	$new_array = array();
	foreach ( $line_items as $item ) {
		if ( ! isset( $item['id'] ) ) {
			return $line_items;
		}

		if ( isset( $item['quantity'] ) && ! isset( $item['qty'] ) ) {
			$item['qty'] = $item['quantity'];
		}
		unset( $item['quantity'] );

		if ( isset( $item['refund_tax'] ) ) {
			$item['refund_tax'] = self::adjust_taxes_for_create_refund_request_line_item( $item['refund_tax'] );
		}

		$id               = $item['id'];
		$new_array[ $id ] = $item;

		unset( $new_array[ $id ]['id'] );
	}

	return $new_array;
}