Last active
August 9, 2016 07:20
-
-
Save xadapter/787a167d35e3e0ff314d83d1b065da1f to your computer and use it in GitHub Desktop.
Change WooCommerce Cart / Checkout Options based on User Role and 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
add_action('woocommerce_available_payment_gateways', 'xa_change_optins_based_on_user_role'); | |
function xa_change_optins_based_on_user_role(){ | |
global $woocommerce; | |
// Check with the capability which is unique to the particular user role. | |
if( current_user_can( 'edit_posts' ) { | |
// | |
if ( isset( $available_gateways['ccavenue'] ) && $woocommerce->customer->get_country() <> 'IN' ) { | |
unset( $available_gateways['ccavenue'] ); | |
} else if ( isset( $available_gateways['paypal'] ) && $woocommerce->customer->get_country() == 'IN' ) { | |
unset( $available_gateways['paypal'] ); | |
} | |
return $available_gateways; | |
} | |
return $available_gateways; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment