Search code examples
wordpressgravity-forms-plugingravityforms

How to update the Total Entries on Gravity Forms using gform_product_info


The hook below override the total on the gravity forms and show the users the discounted total amount based on the qty.

<script type="text/javascript">
gform.addFilter( 'gform_product_total', function(total, formId){

if(formId != 11)
return total;
if(jQuery("#input_11_6").val() > 2){
     total *= .6;
    return total;
} else if (jQuery("#input_11_6").val() > 1) {
    total *= .7;
    return total;
}
else if (jQuery("#input_11_6").val() != 1) {
    return total;
}
return total;

} );

now my problem is when checking the user entries in the backend it shows the original total amount. any advice would be a great help.


Solution

  • in order to update the entries in the backend, you need to add a filter on your theme function.php

     add_filter( 'gform_product_info', function( $product_info, $form, $entry ) {
    // add your code here.
    
    }, 10, 3 );
    

    example code here. https://pastebin.com/xgYYXyTh