woocommerce_coupon_error

woocommerce_coupon_error

Appears in: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Hook Type: filter
See hook in action

See hook in core

Displaying hooks found in version: woocommerce.9.8.1

apply_filters('woocommerce_coupon_error') is found 3 times:

  • /includes/class-wc-coupon.php line 1121
    1117
    1118
    1119
    1120
    1121
    1122
    1123
    1124
    1125
    1126
    1127
            default:
                $err = '';
                break;
        }
        return apply_filters( 'woocommerce_coupon_error', $err, $err_code, $this );
    }
     
    /**
     * 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.
  • /includes/class-wc-coupon.php line 1145
    1141
    1142
    1143
    1144
    1145
    1146
    1147
    1148
    1149
    1150
    1151
                $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 );
    }
     
    /**
     * Get the coupon information that is needed to reapply the coupon to an existing order.
     * This information is intended to be stored as a meta value in the order line item corresponding to the coupon
     * and should NOT be modified or extended (additional/custom data should go in a separate metadata entry).
  • /includes/class-wc-discounts.php line 1074
    1070
    1071
    1072
    1073
    1074
    1075
    1076
    1077
    1078
    1079
    1080
    * @param string    $error_message Error message.
     * @param int       $error_code    Error code.
     * @param WC_Coupon $coupon        Coupon data.
     */
    $message = apply_filters( 'woocommerce_coupon_error', is_numeric( $e->getMessage() ) ? $coupon->get_coupon_error( $e->getMessage() ) : $e->getMessage(), $e->getCode(), $coupon );
     
    $additional_data = array(
        'status' => 400,
    );
     
    $context_coupon_errors = $coupon->get_context_based_coupon_errors( $e->getCode() );

See this hook used in plugins: