WC_Discounts::validate_coupon_expiry_date
Ensure coupon date is valid or throw exception.
Method of the class: WC_Discounts{}
Hooks from the method
Returns
true|false.
Usage
// protected - for code of main (parent) or child class $result = $this->validate_coupon_expiry_date( $coupon );
- $coupon(WC_Coupon) (required)
- Coupon data.
Changelog
| Since 3.2.0 | Introduced. |
WC_Discounts::validate_coupon_expiry_date() WC Discounts::validate coupon expiry date code WC 10.5.0
protected function validate_coupon_expiry_date( $coupon ) {
if ( $coupon->get_date_expires() && apply_filters( 'woocommerce_coupon_validate_expiry_date', time() > $coupon->get_date_expires()->getTimestamp(), $coupon, $this ) ) {
throw new Exception(
sprintf(
/* translators: %s: coupon code */
esc_html__( 'Coupon "%s" has expired.', 'woocommerce' ),
esc_html( $coupon->get_code() )
),
107
);
}
return true;
}