The gform_product_field_types filter allows you to modify the input types used when checking if a field is a product field, enabling support for custom product fields.
Usage
add_filter('gform_product_field_types', 'your_function_name');
Parameters
- $product_fields (array): An array of product field types. The default product types are:
array( 'option', 'quantity', 'product', 'total', 'shipping', 'calculation', 'price', 'hiddenproduct', 'singleproduct', 'singleshipping' )
More information
See Gravity Forms Docs: gform_product_field_types
Examples
Adding a custom product field type
This example adds ‘my_custom_product’ as a new product field type if it is not already in the array of product field types.
add_filter('gform_product_field_types', 'set_product_types'); function set_product_types($product_types) { if (!in_array('my_custom_product', $product_types)) { $product_types[] = 'my_custom_product'; } return $product_types; }
Note: Remember to place this code in the functions.php
file of your active theme.