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 9.7.1
protected function validate_coupon_email_restriction( \WC_Coupon $coupon, \WC_Order $order ) { $restrictions = $coupon->get_email_restrictions(); // Email is forced lowercase like in validate_coupon_allowed_emails. $billing_email = strtolower( $order->get_billing_email() ); if ( ! empty( $restrictions ) && $billing_email && ! DiscountsUtil::is_coupon_emails_allowed( array( $billing_email ), $restrictions ) ) { // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped throw new Exception( $coupon->get_coupon_error( \WC_Coupon::E_WC_COUPON_NOT_YOURS_REMOVED ) ); } }