WC_Coupon::is_valid()publicWC 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.

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.

WC_Coupon::is_valid() code WC 8.7.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;
}