WC_Coupon::is_valid
Deprecated since 3.2.0 In favor of WC_Discounts->is_coupon_valid.. It is no longer supported and may be removed in future releases. It is recommended to replace this function with the same one.
Check if a coupon is valid for the cart.
Method of the class: WC_Coupon{}
No Hooks.
Returns
true|false.
Usage
$WC_Coupon = new WC_Coupon(); $WC_Coupon->is_valid();
Changelog
| Deprecated since 3.2.0 | In favor of WC_Discounts->is_coupon_valid. |
WC_Coupon::is_valid() WC Coupon::is valid code WC 10.6.2
public function is_valid() {
$discounts = new WC_Discounts( WC()->cart );
$valid = $discounts->is_coupon_valid( $this );
if ( is_wp_error( $valid ) ) {
$this->error_message = $valid->get_error_message();
return false;
}
return $valid;
}