Last active
November 22, 2021 20:32
-
-
Save spivurno/cfb2ad05a62d7c76edcba9656634e066 to your computer and use it in GitHub Desktop.
Gravity Perks // GP eCommerce Fields // Set Tax Amount Dynamically
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 Perks // GP eCommerce Fields // Set Tax Amount Dynamically | |
* https://gravitywiz.com/documentation/gravity-forms-ecommerce-fields/ | |
*/ | |
add_filter( 'gform_pre_render_123', 'gpecf_dynamic_tax_amount' ); | |
add_filter( 'gform_pre_validation_123', 'gpecf_dynamic_tax_amount' ); | |
add_filter( 'gform_pre_submission_filter_123', 'gpecf_dynamic_tax_amount' ); | |
add_filter( 'gform_admin_pre_render_123', 'gpecf_dynamic_tax_amount' ); | |
function gpecf_dynamic_tax_amount( $form ) { | |
if( $form['fields'][0]->is_form_editor() ) { | |
return $form; | |
} | |
foreach( $form['fields'] as &$field ) { | |
if( $field->id == 4 ) { | |
$field->taxAmount = 25; | |
} | |
} | |
return $form; | |
} |
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/gp-ecommerce-fields/gpecf-set-tax-amount-dynamically.php