Automattic\WooCommerce\Internal\RestApi\Routes\V4\Orders\Schema

OrderSchema::calculate_order_can_be_refundedprivateWC 1.0

Determine whether an order can be refunded.

An order can be refunded when its status allows refunds and it has remaining refundable amount.

Method of the class: OrderSchema{}

No Hooks.

Returns

true|false.

Usage

// private - for code of main (parent) class only
$result = $this->calculate_order_can_be_refunded( $order ): bool;
$order(WC_Order) (required)
Order instance.

OrderSchema::calculate_order_can_be_refunded() code WC 10.9.4

private function calculate_order_can_be_refunded( WC_Order $order ): bool {
	if ( ! in_array( $order->get_status(), DataUtils::REFUNDABLE_STATUSES, true ) ) {
		return false;
	}
	return (float) $order->get_remaining_refund_amount() > 0;
}