Guest User

Untitled

a guest
Apr 21st, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. function payment_gateway_disable_country( $available_gateways ) {
  2. global $woocommerce;
  3. if ( is_admin() ) return;
  4. if ( isset( $available_gateways['authorize'] ) && $woocommerce->customer->get_billing_country() <> 'US' ) {
  5. unset( $available_gateways['authorize'] );
  6. } else if ( isset( $available_gateways['paypal'] ) && $woocommerce->customer->get_billing_country() == 'US' ) {
  7. unset( $available_gateways['paypal'] );
  8. }
  9. return $available_gateways;
  10. }
  11.  
  12. add_filter( 'woocommerce_available_payment_gateways', 'payment_gateway_disable_country' );
Add Comment
Please, Sign In to add comment