Last active
November 23, 2022 16:47
-
-
Save spivurno/7e067632f17554ca541e to your computer and use it in GitHub Desktop.
Gravity Wiz // Gravity Forms // Filter Out $0.00 Products
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 $0.00 Products | |
* http://gravitywiz.com/ | |
*/ | |
add_filter( 'gform_product_info', 'gw_remove_empty_products', 10, 3 ); | |
function gw_remove_empty_products( $product_info, $form, $lead ) { | |
$products = array(); | |
foreach( $product_info['products'] as $field_id => $product ) { | |
if( GFCommon::to_number( $product['price'] ) != 0 ) { | |
$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
👉 This Gist has been migrated to the Gravity Wiz Snippet Library:
https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-gravity-forms-filter-out-zero-dollar-products.php