我希望在后面的页面上调用联系人表单7字段输入。当前流程是用户填写cf7表单,表单重定向到签名插件(ApproveMe),然后使用WPSimple Pay支付支付页面。我有一个使用HTML变量自动将总金额添加到表单的函数。
我的functions.php包含以下内容:
function simpay_custom_form_35_amount( $amount )
{
$url_var = 'amount';
$value = isset( $_GET[ $url_var ] ) ? sanitize_text_field( $_GET[ $url_var ] ) : $default;
return $value;
}
add_filter( 'simpay_form_35_amount', 'simpay_custom_form_35_amount' );这允许我设置要收费的表单数量:https://paymentpage/?amount=250
如果我的URL包含?amount=xxx以使用URL设置,但如果URL未指定任何内容,则默认为之前提交的联系人Form7值。
发布于 2020-05-13 07:49:52
使用以下命令创建cookie
(function($){
$(document).on('click', '.wpcf7-submit', function(){
if($('.total-cost .ctf7-total').length && $('.total-cost .ctf7-total').attr('data-number')){
document.cookie = "sy_total_val="+$('.total-cost .ctf7-total').attr('data-number') + '; path=/';
}
});
})(jQuery);total-cost是来自cf7的字段,我想通过。
然后将cookie设为默认值,但如果存在URL变量,则将其覆盖
function simpay_custom_form_35_amount( $amount ) {
$url_var = 'amount';
if(!empty($_COOKIE["sy_total_val"])) $default = sanitize_text_field($_COOKIE["sy_total_val"]);
$value = isset( $_GET[ $url_var ] ) ? sanitize_text_field( $_GET[ $url_var ] ) : $default;
return $value;
}
add_filter( 'simpay_form_35_amount', 'simpay_custom_form_35_amount' );https://stackoverflow.com/questions/61757582
复制相似问题