Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alidemirci/58006775e54a1132472f15a6fbf5c999 to your computer and use it in GitHub Desktop.
Save alidemirci/58006775e54a1132472f15a6fbf5c999 to your computer and use it in GitHub Desktop.
Disable WooCommerce Payment Method for Specific Country
apply_filters( 'woocommerce_available_payment_gateways', $_available_gateways );
add_filter( 'woocommerce_available_payment_gateways', 'amc_remove_payment_method');
function amc_remove_payment_method( $_available_gateways ){
if( class_exists( 'WooCommerce' ) ) :
// Get All Payment Methods
$payments = $_available_gateways;
if ( isset( $payments['paypal'] ) ) :
if( WC()->customer->get_billing_country() == "FR" ) :
// Remove Paypal Method
unset($payments['paypal']);
endif;
endif;
// Send Payment Method without Paypal
return $payments;
endif;
}
@alidemirci
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment