WC_Coupon::get_generic_coupon_error()public staticWC 1.0

Map one of the WC_Coupon error codes to an error string. No coupon instance will be available where a coupon does not exist, so this static method exists.

Method of the class: WC_Coupon{}

Hooks from the method

Return

String. Error string.

Usage

$result = WC_Coupon::get_generic_coupon_error( $err_code );
$err_code(int) (required)
Error code.

WC_Coupon::get_generic_coupon_error() code WC 8.7.0

public static function get_generic_coupon_error( $err_code ) {
	switch ( $err_code ) {
		case self::E_WC_COUPON_NOT_EXIST:
			$err = __( 'Coupon does not exist!', 'woocommerce' );
			break;
		case self::E_WC_COUPON_PLEASE_ENTER:
			$err = __( 'Please enter a coupon code.', 'woocommerce' );
			break;
		default:
			$err = '';
			break;
	}
	// When using this static method, there is no $this to pass to filter.
	return apply_filters( 'woocommerce_coupon_error', $err, $err_code, null );
}