Created
January 29, 2016 13:56
-
-
Save akther80/a154f0fbc53f9be2d6fc to your computer and use it in GitHub Desktop.
Payment Gateway enable for few states in wocommerce
This file contains hidden or 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
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