Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DevinVinson/6238355 to your computer and use it in GitHub Desktop.
Save DevinVinson/6238355 to your computer and use it in GitHub Desktop.
Remove woocommerce gateways for $country, remove gateways for anything else
function lk_aussie_gateways( $available_gateways ) {
global $woocommerce;
if ($woocommerce->customer->get_country() == 'AU') {
unset( $available_gateways['cod'] );
}
return $available_gateways;
}
add_filter( 'woocommerce_available_payment_gateways', 'lk_aussie_gateways');
function lk_non_aussie_gateways( $available_gateways ) {
global $woocommerce;
if ($woocommerce->customer->get_country() <> 'AU' ) {
unset ($available_gateways['paypal']);
unset ($available_gateways['cheque']);
}
return $available_gateways;
}
add_filter( 'woocommerce_available_payment_gateways', 'lk_non_aussie_gateways');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment