Last active
April 4, 2020 21:11
-
-
Save growdev/4a1426305d0f425a5486 to your computer and use it in GitHub Desktop.
Remove Unused Payment Gateways from Dashboard
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
<?php | |
add_filter( 'woocommerce_payment_gateways', 'growdev_remove_unused_payment_gateways', 20, 1 ); | |
/** | |
* This function will remove all of the WooCommerce standard gateways from the | |
* WooCommerce > Settings > Checkout dashboard. | |
* @see current default gateways https://github.com/woocommerce/woocommerce/blob/master/includes/class-wc-payment-gateways.php#L77-L85 | |
*/ | |
function growdev_remove_unused_payment_gateways( $load_gateways ) { | |
$remove_gateways = array( | |
'WC_Gateway_BACS', | |
'WC_Gateway_Cheque', | |
'WC_Gateway_COD', | |
'WC_Gateway_Paypal' | |
); | |
foreach ( $load_gateways as $key => $value ) { | |
if ( in_array( $value, $remove_gateways ) ) { | |
unset( $load_gateways[ $key ] ); | |
} | |
} | |
return $load_gateways; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just change that loop for:
$load_gateways = array_diff( $load_gateways, $remove_gateways );