Set minimum donation amount [RESOLVED]

Hello Everyone,

I want to know if the below script can be modified to accept the amount in INR (Indian rupees)


add_filter( 'gform_field_validation_225_8', 'donate_minimum_validation', 10, 4 );
function donate_minimum_validation( $result, $value, $form, $field ) {
    $min_amount = 25.00;
    $donated = str_replace('$', '', $value);
    if ( $donated < $min_amount ) {
        $result['is_valid'] = false;
        $result['message'] = 'A minimum amount of $'.$min_amount.'.00 is required to offset credit card processing fees.';
    }
    return $result;
}

Thanks
Pratik

Yes, this can be modified to work with INR. The part that would need to change is the str_replace part - that is stripping off the currency symbol. For INR, this will be different. Try using this:

// apply to form 225, field 8
add_filter( 'gform_field_validation_225_8', 'donate_minimum_validation', 10, 4 );
function donate_minimum_validation( $result, $value, $form, $field ) {
    $min_amount = 25.00;
    $donated = GFCommon::to_number( $value, 'INR' );
    if ( $donated < $min_amount ) {
        $result['is_valid'] = false;
        $result['message'] = 'A minimum amount of '.$min_amount.'INR is required to offset credit card processing fees.';
    }
    return $result;
}

Hi Chris,

I am all set now.

Thank you so much for your help, much appreciated.

Stay safe :slight_smile:

Cheers,
Pratik

1 Like