WooCommerce-隐藏付款网关 [英] WooCommerce - hide payment gateway

查看:135
本文介绍了WooCommerce-隐藏付款网关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在WooCommerce上为特定客户隐藏付款网关插件,例如,如果客户的名字是:Peter,则该插件不会为他显示.

How I can hide a payment-gateway plugin for specific customer on WooCommerce , for example if the customer's first name is : Peter , the plugin will not show for him.

例如: Woocommerce隐藏用于用户角色的支付网关

推荐答案

我希望这对您有用,如果仍然存在任何问题,请告诉我.

I hope this will work for you , if any problem persist please let me know.

   function woo_disable_cod( $available_gateways ) {
        $current_user = wp_get_current_user();
        //check whether the avaiable payment gateways have Cash on delivery and user is not logged in or he is a user with role customer
        if ( isset($available_gateways['cod']) && ((current_user_can('customer') && $current_user->user_firstname == 'Peter' ) || ! is_user_logged_in() ) ) {

            //remove the paypal payment gateway from the available gateways.

             unset($available_gateways['paypal']);
         }
         return $available_gateways;
    }

    add_filter('woocommerce_available_payment_gateways', 'woo_disable_cod', 99, 1);

这篇关于WooCommerce-隐藏付款网关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆