如何使用 gform_product_info 更新重力表的总条目数

How to update the Total Entries on Gravity Forms using gform_product_info

下面的钩子会覆盖重力表上的总数,并向用户显示基于数量的折扣总额。

<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;

} );

现在我的问题是在后台检查用户条目时显示的是原始总金额。任何建议都会有很大帮助。

为了更新后端的条目,您需要在主题上添加过滤器 function.php

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

}, 10, 3 );

示例代码在这里。 https://pastebin.com/xgYYXyTh