Automattic\WooCommerce\Internal\RestApi\Routes\V4\Refunds

DataUtils::convert_line_item_taxes_to_internal_formatprivateWC 1.0

Convert line item taxes (schema format) to internal format. This keys arrays by tax ID and has some different naming

Method of the class: DataUtils{}

No Hooks.

Returns

Array. The converted taxes.

Usage

// private - for code of main (parent) class only
$result = $this->convert_line_item_taxes_to_internal_format( $line_item_taxes );
$line_item_taxes(array) (required)
The taxes to convert.

DataUtils::convert_line_item_taxes_to_internal_format() code WC 10.4.3

private function convert_line_item_taxes_to_internal_format( $line_item_taxes ) {
	$prepared_taxes = array();

	foreach ( $line_item_taxes as $line_item_tax ) {
		if ( ! isset( $line_item_tax['id'], $line_item_tax['refund_total'] ) ) {
			continue;
		}
		$prepared_taxes[ $line_item_tax['id'] ] = $line_item_tax['refund_total'];
	}

	return $prepared_taxes;
}