Using Gravity Forms ‘gform_payment_amount’ PHP filter

The gform_payment_amount Gravity Forms PHP filter allows you to modify the payment amount displayed for the entry in the Payment Details section.

Usage

add_filter('gform_payment_amount', 'your_function_name', 10, 3);

Parameters

  • $payment_amount (string): The payment amount for the entry.
  • $form (Form Object): The form.
  • $entry (Entry Object): The entry.

More information

See Gravity Forms Docs: gform_payment_amount

Examples

Add currency symbol to payment amount

This example adds a “USD” prefix to the payment amount.

add_filter('gform_payment_amount', 'change_payment_amount', 10, 3);

function change_payment_amount($payment_amount, $form, $entry){
    return 'USD ' . $payment_amount;
}

Apply a discount based on a coupon code

This example applies a 10% discount if the coupon code “SAVE10” is entered.

add_filter('gform_payment_amount', 'apply_discount', 10, 3);

function apply_discount($payment_amount, $form, $entry){
    $coupon_code = rgar($entry, '1');
    if ($coupon_code == 'SAVE10') {
        $payment_amount *= 0.9;
    }
    return $payment_amount;
}

Add a fixed handling fee

This example adds a fixed $5 handling fee to the payment amount.

add_filter('gform_payment_amount', 'add_handling_fee', 10, 3);

function add_handling_fee($payment_amount, $form, $entry){
    $handling_fee = 5;
    return $payment_amount + $handling_fee;
}

Apply a discount for a specific form

This example applies a 20% discount only for form ID 3.

add_filter('gform_payment_amount', 'form_specific_discount', 10, 3);

function form_specific_discount($payment_amount, $form, $entry){
    if ($form['id'] == 3) {
        $payment_amount *= 0.8;
    }
    return $payment_amount;
}

Apply tax based on user location

This example adds a 10% tax for users located in California.

add_filter('gform_payment_amount', 'apply_tax', 10, 3);

function apply_tax($payment_amount, $form, $entry){
    $user_state = rgar($entry, '2');
    if ($user_state == 'California') {
        $payment_amount *= 1.1;
    }
    return $payment_amount;
}