Last active
February 28, 2019 01:42
Gravity Wiz // Gravity Forms // Exclude Products By Field ID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Gravity Wiz // Gravity Forms // Filter Out Products By Field ID | |
* http://gravitywiz.com/ | |
*/ | |
add_filter( 'gform_product_info', 'gw_remove_products_by_id', 10, 3 ); | |
function gw_remove_empty_products( $product_info, $form, $lead ) { | |
$remove_products = array( 1 ); | |
$products = array(); | |
foreach( $product_info['products'] as $field_id => $product ) { | |
if( ! in_array( $field_id, $remove_products ) ) { | |
$products[ $field_id ] = $product; | |
} | |
} | |
$product_info['products'] = $products; | |
return $product_info; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment