WordPress at Your Fingertips
function is not described

WC_Coupon::is_valid() public WC 1.0

Deprecated from version 3.2.0 In favor of WC_Discounts->is_coupon_valid.. It is no longer supported and can 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.

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

No Hooks.

Return

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.

Code of WC_Coupon::is_valid() WC 5.6.0

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;
}