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.

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

No Hooks.




$WC_Coupon = new WC_Coupon();


Deprecated Since 3.2.0 In favor of WC_Discounts->is_coupon_valid.

Code of WC_Coupon::is_valid() WC 6.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;