Automattic\WooCommerce\StoreApi\Utilities
OrderController::validate_coupon_email_restriction()
Check email restrictions of a coupon against the order.
Метод класса: OrderController{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->validate_coupon_email_restriction( $coupon, $order );
- $coupon(\WC_Coupon) (обязательный)
- Coupon object applied to the cart.
- $order(\WC_Order) (обязательный)
- Order object.
Код OrderController::validate_coupon_email_restriction() OrderController::validate coupon email restriction WC 8.7.0
protected function validate_coupon_email_restriction( \WC_Coupon $coupon, \WC_Order $order ) { $restrictions = $coupon->get_email_restrictions(); if ( ! empty( $restrictions ) && $order->get_billing_email() && ! wc()->cart->is_coupon_emails_allowed( array( $order->get_billing_email() ), $restrictions ) ) { throw new Exception( $coupon->get_coupon_error( \WC_Coupon::E_WC_COUPON_NOT_YOURS_REMOVED ) ); } }