Php 当我在电子商务中的自定义字段上放置文本时自动更改支付网关

Php 当我在电子商务中的自定义字段上放置文本时自动更改支付网关,php,jquery,wordpress,woocommerce,Php,Jquery,Wordpress,Woocommerce,在WooCommerce结帐页面中是否有这样做的方法 我只想在WooCommerce结帐页面中有一个自定义的textarea字段,当我开始在textarea中写入内容时,支付网关将自动从paypal更改为支票 好的,假设您的文本区域id是 在functions.php中 function bh_change_gateway() {?> <script> jQuery('#txt1').keyup(function(){ jQuery( '.payment_methods inp

在WooCommerce结帐页面中是否有这样做的方法

我只想在WooCommerce结帐页面中有一个自定义的textarea字段,当我开始在textarea中写入内容时,支付网关将自动从paypal更改为支票

好的,假设您的文本区域id是

functions.php中

function bh_change_gateway() {?>
<script>
jQuery('#txt1').keyup(function(){
jQuery( '.payment_methods input.input-radio' ).removeProp('checked');
jQuery( '#your_payment_gateway_id').attr("checked", "checked");
})
</script>


<?}

add_action('woocommerce_review_order_before_submit','bh_change_gateway' );
函数bh\u change\u gateway(){?>
jQuery('#txt1').keyup(函数(){
jQuery('.payment_方法input.input radio').removeProp('checked');
jQuery(“#您的"支付"网关"id”).attr(“已检查”、“已检查”);
})

你能详细说明一下你到底想要在woocommerce结账页面中做什么吗?我可能错了,但是,显然,在我看来,你正在寻找一种依赖注入式的解决方案,其中依赖项位于文本区域的文本中。目前在结账页面中,有两种付款方式,paypal和支票……我已经创建了一个Extra结帐页面中的文本区域,当他们在那里写东西时,付款将更改为仅支票并删除paypal