Using Gravity Forms ‘gform_product_unitprice’ PHP filter

The gform_product_unitprice filter allows you to modify the “Unit Price” heading when displaying the order information grid on the entry detail page and notification emails.

Usage

add_filter('gform_product_unitprice', 'change_unitprice', 10, 2);
function change_unitprice($label, $form_id) {
    // your custom code here
    return $label;
}

Parameters

  • $label (string): The label to be filtered.
  • $form_id (integer): The current form’s ID.

More information

See Gravity Forms Docs: gform_product_unitprice

Examples

Change Unit Price Label

Change the default “Unit Price” label to “Sub Total”:

add_filter('gform_product_unitprice', 'change_unitprice', 10, 2);
function change_unitprice($label, $form_id) {
    return 'Sub Total';
}

Add Currency Symbol

Add a currency symbol before the “Unit Price” label:

add_filter('gform_product_unitprice', 'add_currency_symbol', 10, 2);
function add_currency_symbol($label, $form_id) {
    return '$' . $label;
}

Change Label Based on Form ID

Change the “Unit Price” label based on the form ID:

add_filter('gform_product_unitprice', 'change_label_based_on_form_id', 10, 2);
function change_label_based_on_form_id($label, $form_id) {
    if ($form_id == 1) {
        return 'Price per Item';
    }
    return $label;
}

Add Form ID to Label

Add the form ID to the “Unit Price” label:

add_filter('gform_product_unitprice', 'add_form_id_to_label', 10, 2);
function add_form_id_to_label($label, $form_id) {
    return $label . ' (Form ID: ' . $form_id . ')';
}

Make Label Uppercase

Change the “Unit Price” label to uppercase:

add_filter('gform_product_unitprice', 'make_label_uppercase', 10, 2);
function make_label_uppercase($label, $form_id) {
    return strtoupper($label);
}