Last active
June 20, 2019 20:32
-
-
Save cccamuseme/2627d5889b7d75c82d367cc5ea015ea0 to your computer and use it in GitHub Desktop.
Enable or disable woocommerce payment gateway by ACF radio buttons in user profile.
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
<?php | |
/* | |
* Enable COD for account holder | |
*/ | |
function enable_cod_payment( $available_gateways ) { | |
global $woocommerce; | |
$user = wp_get_current_user(); | |
$user_status = get_field('account_holder', $user ); | |
if ($user_status == 'Yes') { | |
$available_gateways['cod']; | |
unset( $available_gateways['authorize_net_cim_credit_card'] ); | |
} | |
else { | |
unset( $available_gateways['cod'] ); | |
} | |
return $available_gateways; | |
} | |
add_filter( 'woocommerce_available_payment_gateways', 'enable_cod_payment' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment