Skip to content

Instantly share code, notes, and snippets.

@hussong
Created February 10, 2016 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hussong/d9e4e33435050dcd6bbd to your computer and use it in GitHub Desktop.
Save hussong/d9e4e33435050dcd6bbd to your computer and use it in GitHub Desktop.
WooCommerce show Cash on Delivery for specific customer country only
function my_payment_gateways( $available_gateways ) {
global $woocommerce;
/* Remove CoD if shipping outside of DE */
if ( isset( $available_gateways['cod'] ) && $woocommerce->customer->get_country() != 'DE' ) {
unset( $available_gateways['cod'] );
}
return $available_gateways;
}
add_filter( 'woocommerce_available_payment_gateways', 'my_payment_gateways' );
@rivacopor
Copy link

Thanks! How does it looks like when i want wo enable the gateway invoice only in DE?

@albert0346
Copy link

How would the function look like when I want to have COD only for some countries? In addition to this would there be a way to have one COD-fee for Germany and for the other countries another COD-fee?

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