gform_product_price

Description

Use this filter to change the sub-label for the Product Price input.

Usage

The following would apply to all forms:

add_filter( 'gform_product_price', 'your_function_name', 10, 2 );

You can also target a specific form by adding the form id after the hook name. (format: gform_product_price_FORMID)

add_filter( 'gform_product_price_6', 'your_function_name', 10, 2 );

Parameters

  • $sublabel string
    The sub-label to be filtered.
  • $form_id integer
    ID of current form.

Examples

This example changes the price sub-label to “Cost:” only for form id 185. Change this number to apply it to a different form or remove _185 to apply the filter to all forms.

add_filter( 'gform_product_price_185', function ( $sublabel, $form_id ) {
	GFCommon::log_debug( __METHOD__ . '(): Running...' );
	return 'Cost';
}, 10, 2 );

Please note: The colon will be added automatically after the label.

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Source Code

This filter is located in the following methods:

  • GFCommon::get_submitted_pricing_fields() in common.php
  • GFEntryDetail::lead_detail_grid() in entry_detail.php
  • GF_Field_Calculation::get_field_input() in includes/fields/class-gf-field-calculation.php
  • GF_Field_SingleProduct::get_field_input() in includes/fields/class-gf-field-singleproduct.php