Automattic\WooCommerce\Internal\RestApi\Routes\V4\Refunds
DataUtils::line_refund_history_matches_quantities
Whether every prior refund line for a product matches its quantity-derived amount.
True means the difference between the line's refunded total and the sum of unit-price amounts is pure rounding drift, so the final-chunk top-up in {@see compute_quantity_refund_total()} can safely reconcile it. Gross values are compared as formatted decimals at currency precision — never raw float equality. A refund line with no units (qty 0, the dollar-only form) is off-schedule by definition.
Method of the class: DataUtils{}
No Hooks.
Returns
bool.
Usage
// private - for code of main (parent) class only $result = $this->line_refund_history_matches_quantities( $item, $line_refunds ): bool;
- $item(WC_Order_Item_Product) (required)
- The original order line.
- $line_refunds(array) (required)
- Prior refund lines as list<array{qty: int, gross: float}> (positive magnitudes).
DataUtils::line_refund_history_matches_quantities() DataUtils::line refund history matches quantities code WC 11.1.2
private function line_refund_history_matches_quantities( WC_Order_Item_Product $item, array $line_refunds ): bool {
$price_decimals = wc_get_price_decimals();
foreach ( $line_refunds as $refund_line ) {
if ( $refund_line['qty'] <= 0 ) {
return false;
}
$expected = abs( $this->compute_line_item_refund_total( $item, $refund_line['qty'] ) );
if ( wc_format_decimal( $refund_line['gross'], $price_decimals ) !== wc_format_decimal( $expected, $price_decimals ) ) {
return false;
}
}
return true;
}