WordPress at Your Fingertips
function is not described

WC_Discounts::validate_coupon_exists() protected WC 3.2.0

Ensure coupon exists or throw exception.

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

No Hooks.

Return

true|false.

Usage

// protected - for code of main (parent) or child class
$result = $this->validate_coupon_exists( $coupon );
$coupon(WC_Coupon) (required)
Coupon data.

Changelog

Since 3.2.0 Introduced.

Code of WC_Discounts::validate_coupon_exists() WC 5.6.0

protected function validate_coupon_exists( $coupon ) {
	if ( ! $coupon->get_id() && ! $coupon->get_virtual() ) {
		/* translators: %s: coupon code */
		throw new Exception( sprintf( __( 'Coupon "%s" does not exist!', 'woocommerce' ), esc_html( $coupon->get_code() ) ), 105 );
	}

	return true;
}