Automattic\WooCommerce\Admin\API\Reports\Orders\Stats

DataStore::should_split_full_refund_using_parent_orderprotected staticWC 1.0

Whether this refund is a single lump-sum refund for the full order (e.g. status set to refunded without line items).

Method of the class: DataStore{}

No Hooks.

Returns

bool.

Usage

$result = DataStore::should_split_full_refund_using_parent_order( $refund, $parent_order );
$refund(WC_Order_Refund|OrderRefund|Order) (required)
Refund order.
$parent_order(WC_Order|Order) (required)
Parent order (not a refund).

DataStore::should_split_full_refund_using_parent_order() code WC 11.1.1

protected static function should_split_full_refund_using_parent_order( $refund, $parent_order ) {
	// The parent must be the original order, not another refund.
	if ( ! $parent_order instanceof WC_Order || 'shop_order_refund' === $parent_order->get_type() ) {
		return false;
	}

	if ( self::get_num_items_sold( $refund ) > 0 ) {
		return false;
	}

	$parent_refunds = $parent_order->get_refunds();
	if ( 1 !== count( $parent_refunds ) ) {
		return false;
	}

	$refund_total = wc_format_decimal( abs( (float) $refund->get_total() ) );
	$order_total  = wc_format_decimal( (float) $parent_order->get_total() );

	return $refund_total === $order_total;
}