Last active
March 5, 2020 13:03
-
-
Save alidemirci/58006775e54a1132472f15a6fbf5c999 to your computer and use it in GitHub Desktop.
Disable WooCommerce Payment Method for Specific Country
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source