You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在WooCommerce中禁用订单确认页的指定支付方式?

禁用WooCommerce订单确认页指定支付方式

可以通过以下两种方式实现需求:

方法1:自定义代码实现

  1. 先确认目标支付方式的ID:
    • 进入WooCommerce后台的「支付」设置,点击对应支付方式的「管理」按钮,查看浏览器地址栏的section参数(比如地址栏显示section=wc_gateway_cod,则该支付方式ID为cod)。常见支付方式ID参考:货到付款是cod、PayPal是paypal、Stripe是stripe。
  2. 将以下代码添加到当前主题的functions.php文件(推荐使用子主题,避免主题更新导致代码丢失):
add_filter( 'woocommerce_available_payment_gateways', 'disable_payment_on_order_review' );
function disable_payment_on_order_review( $gateways ) {
    // 判断当前是否处于订单确认页(结账审核页)
    if ( is_checkout() && ! is_wc_endpoint_url( 'order-pay' ) ) {
        // 替换为你需要禁用的支付方式ID
        $target_gateway = 'cod';
        if ( isset( $gateways[ $target_gateway ] ) ) {
            unset( $gateways[ $target_gateway ] );
        }
    }
    return $gateways;
}

代码说明:通过woocommerce_available_payment_gateways钩子过滤可用支付方式,只在订单确认页移除指定的支付选项,不影响其他页面的支付方式展示。

方法2:插件实现(无需代码)

安装并激活类似「Payment Gateway Based on Shipping & Cart Conditions」的插件,操作步骤如下:

  • 进入插件设置页面,添加新规则
  • 选择条件类型为「页面」,设置为「结账页」
  • 勾选需要禁用的支付方式,保存规则即可

注意:使用插件前需确认插件与当前WooCommerce版本兼容,避免出现功能冲突。

内容的提问来源于stack exchange,提问作者Karim Krimou

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 06:40:28