Automattic\WooCommerce\Internal\Orders

IppFunctions::is_order_in_person_payment_eligible()public staticWC 1.0

Returns if order is eligible to accept In-Person Payments.

Метод класса: IppFunctions{}

No Hooks.

Return

true|false. true if order is eligible, false otherwise

Usage

$result = IppFunctions::is_order_in_person_payment_eligible( $order ): bool;
$order(WC_Order) (required)
order that the conditions are checked for.

Код IppFunctions::is_order_in_person_payment_eligible() WC 7.1.0

public static function is_order_in_person_payment_eligible( WC_Order $order ): bool {
	$has_status            = in_array( $order->get_status(), array( 'pending', 'on-hold', 'processing' ), true );
	$has_payment_method    = in_array( $order->get_payment_method(), array( 'cod', 'woocommerce_payments', 'none' ), true );
	$order_is_not_paid     = null === $order->get_date_paid();
	$order_is_not_refunded = empty( $order->get_refunds() );

	$order_has_no_subscription_products = true;
	foreach ( $order->get_items() as $item ) {
		$product = $item->get_product();

		if ( is_object( $product ) && $product->is_type( 'subscription' ) ) {
			$order_has_no_subscription_products = false;
			break;
		}
	}

	return $has_status && $has_payment_method && $order_is_not_paid && $order_is_not_refunded && $order_has_no_subscription_products;
}