Automattic\WooCommerce\StoreApi\Utilities
OrderController::validate_coupon_email_restriction()
Check email restrictions of a coupon against the order.
Method of the class: OrderController{}
No Hooks.
Return
null
. Nothing (null).
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.
OrderController::validate_coupon_email_restriction() OrderController::validate coupon email restriction code 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 ) ); } }