majeedraza

WooCommerce - Filter payment gateways

Apr 11th, 2021 (edited)
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.41 KB | None | 0 0
  1. <?php
  2. // WooCommerce - Filter payment gateways
  3. add_filter( 'woocommerce_available_payment_gateways', 'custom_available_payment_gateways' );
  4. function custom_available_payment_gateways( $gateways ) {
  5.   $current_user_id = get_current_user_id();
  6.   $bad_lad_id = 1; // user id for the customer who can't have COD
  7.   if ( $bad_lad_id == $current_user_id  ) {
  8.     unset( $gateways['cod'] );
  9.   }
  10.   return $gateways;
  11. }
Add Comment
Please, Sign In to add comment