最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

In WooCommerce filter the available Payment Methods by User Role

programmeradmin2浏览0评论
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 4 years ago.

Improve this question

Is it possible to filter available payment methods to certain user roles just using the WooCommerce configuration? Without adding anything to any template file I mean. What I want to achieve is to give the possibility to pay with credit card only to certain users.

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 4 years ago.

Improve this question

Is it possible to filter available payment methods to certain user roles just using the WooCommerce configuration? Without adding anything to any template file I mean. What I want to achieve is to give the possibility to pay with credit card only to certain users.

Share Improve this question asked Jun 20, 2017 at 8:39 SergiSergi 2601 gold badge6 silver badges18 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 9

It is not possible by WooCommerce default configuration.

You have to install below plugin.

https://codecanyon/item/woocommerce-role-based-payment-shipping-methods/18953727

or programmatically, you can refer below link.

https://businessbloomer/disable-payment-gateway-specific-user-role-woocommerce/

You can use following:

  add_filter('woocommerce_available_payment_gateways', 'filter_gateways', 1);
  function filter_gateways($gateways)
  {
      $current_user = wp_get_current_user();
      $role = $current_user->roles;
      global $woocommerce;
      /* add your user role in condition and payment method which you need to unset*/
      if ($role[0] == 'administrator') {
          unset($gateways['cod']);
      }
      return $gateways;
  }
发布评论

评论列表(0)

  1. 暂无评论