Skip to content

Instantly share code, notes, and snippets.

@akther80
Created January 29, 2016 13:56
Show Gist options
  • Save akther80/a154f0fbc53f9be2d6fc to your computer and use it in GitHub Desktop.
Save akther80/a154f0fbc53f9be2d6fc to your computer and use it in GitHub Desktop.
Payment Gateway enable for few states in wocommerce
function payment_gateway_disable_state( $available_gateways ) {
global $woocommerce;
$state = $woocommerce->customer->get_state();
if ( isset( $available_gateways['cod'] ) && ! in_array( $state, array( 'AL', 'AK', 'CA' ) ) ) {
unset( $available_gateways['cod'] );
}
return $available_gateways;
}
add_filter( 'woocommerce_available_payment_gateways', 'payment_gateway_disable_state' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment