WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\StoreApi\Utilities

OrderController::validate_coupon_email_restriction() protected WC 1.0

Check email restrictions of a coupon against the order.

{} It's a method of the class: OrderController{}

No Hooks.

Return

null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->validate_coupon_email_restriction( $coupon, $order );
$coupon(WC_Coupon) (required)
Coupon object applied to the cart.
$order(WC_Order) (required)
Order object.

Code of OrderController::validate_coupon_email_restriction() WC 5.8.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( [ $order->get_billing_email() ], $restrictions ) ) {
		throw new Exception( $coupon->get_coupon_error( \WC_Coupon::E_WC_COUPON_NOT_YOURS_REMOVED ) );
	}
}