Automattic\WooCommerce\Internal\Orders
IppFunctions::is_order_in_person_payment_eligible
Returns if order is eligible to accept In-Person Payments.
Метод класса: IppFunctions{}
Хуков нет.
Возвращает
true|false. true if order is eligible, false otherwise
Использование
$result = IppFunctions::is_order_in_person_payment_eligible( $order ): bool;
- $order(WC_Order) (обязательный)
- order that the conditions are checked for.
Код IppFunctions::is_order_in_person_payment_eligible() IppFunctions::is order in person payment eligible WC 10.7.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( WC_Gateway_COD::ID, '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;
}