gpt4 book ai didi

php - woocommerce 阻止结帐提交付款方式更改

转载 作者:行者123 更新时间:2023-12-05 09:18:19 26 4
gpt4 key购买 nike

您好,我的结帐页面有一些问题,当我在页面上更改付款方式时,结帐订单会自动提交,我想使用按钮手动提交。我尝试使用以下代码来禁用 ajax 调用,但似乎这不是 ajax 问题。

function script_disabled()
{
wp_dequeue_script( 'wc-checkout' );
}

add_action('wp_enqueue_scripts', 'script_disabled');

最佳答案

您对问题的描述有些不对。使用单选按钮更改付款方式不应自动提交订单。在我的安装中,此操作仅显示或隐藏付款方式的相应 Pane 。显示的 Pane 实际上有提交订单的按钮。下面的代码是防止提交 AJAX 调用的 jQuery 事件处理程序。但是,我认为这不是解决您问题的正确方法。您描述的行为不是 WooCommerce 结帐页面的工作方式。至少,它在我的安装中不是这样的,这对于结账页面来说是非常标准的。

jQuery( 'form.checkout' ).on( 'checkout_place_order', function() {
var $payment_method = jQuery( 'form.checkout input[name="payment_method"]:checked' ).val();
if ( /* your condition, e.g. "$payment_method == 'paypal'" */ ) {
// prevent the submit AJAX call
alert( 'submit cancelled!' );
return false;
}
// allow the submit AJAX call
return true;
});

我不会使用此解决方案,因为我认为还有其他问题。

关于php - woocommerce 阻止结帐提交付款方式更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44980756/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com