2014-11-23 22:01
浏览 63


I want to have the cash on delivery option only for price below 100$ and hide it automatically when cart is above 100$. The problem is that, I have 3 different payment methods right now. Paypal, cheque and COD. When a person buy something, and choose cash on delievry method, I've written a description there saying "you can choose COD if your order is below 100$". But some people neglect it and still choose COD even their purchase is above 100$. So, I want to hide COD automatically, when a purchase is above 100$. Hence, when a purchase is above 100$, there would be just two options, Paypal and Cheque. Hope I could clarify it a bit more.


图片转代码服务由CSDN问答提供 功能建议

我希望只有价格低于100美元的货到付款选项,并在购物车高于100时自动隐藏 $。 问题是,我现在有3种不同的付款方式。 Paypal,支票和COD。 当一个人买东西,并选择现金的delievry方法,我写了一个描述说“如果你的订单低于100美元,你可以选择COD”。 但是有些人忽视它并且仍然选择COD,即使他们的购买价格高于100美元。 因此,当购买超过100美元时,我想自动隐藏COD。 因此,当购买超过100美元时,只有两个选项,Paypal和Check。 希望我能更多地澄清一下。

谢谢 < / DIV>

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dp13668681869 2014-11-23 23:03

    You can use the woocommerce_available_payment_gateways hook to edit woocommerce gateways.

    add_filter( 'woocommerce_available_payment_gateways' , 'change_payment_gateway', 20, 1);
     * remove cod gateway if cart total > 100
     * @param $gateways
     * @return mixed
    function change_payment_gateway( $gateways ){
        // Compare cart subtotal (without shipment fees)
        if( WC()->cart->subtotal > 100 ){
             // then unset the 'cod' key (cod is the unique id of COD Gateway)
             unset( $gateways['cod'] );
        return $gateways;
    解决 无用
    打赏 举报