Skip to content

Instantly share code, notes, and snippets.

@bentasm1
Created August 11, 2016 01:09
Show Gist options
  • Save bentasm1/764427ca73cbda9d107838f7598f11e7 to your computer and use it in GitHub Desktop.
Save bentasm1/764427ca73cbda9d107838f7598f11e7 to your computer and use it in GitHub Desktop.
WooCommerce Rotate between 5 payment gateways
function filter_gateways($gateways){
global $woocommerce;
$thewinner = rand(1,5);
if ($thewinner == 1 ) {
unset($gateways['gateway2']);
unset($gateways['gateway3']);
unset($gateways['gateway4']);
unset($gateways['gateway5']);
}
if ($thewinner == 2 ) {
unset($gateways['gateway1']);
unset($gateways['gateway3']);
unset($gateways['gateway4']);
unset($gateways['gateway5']);
}
if ($thewinner == 3 ) {
unset($gateways['gateway1']);
unset($gateways['gateway2']);
unset($gateways['gateway4']);
unset($gateways['gateway5']);
}
if ($thewinner == 4 ) {
unset($gateways['gateway1']);
unset($gateways['gateway2']);
unset($gateways['gateway3']);
unset($gateways['gateway5']);
}
if ($thewinner == 5 ) {
unset($gateways['gateway1']);
unset($gateways['gateway2']);
unset($gateways['gateway3']);
unset($gateways['gateway4']);
}
return $gateways;
}
add_filter('woocommerce_available_payment_gateways','filter_gateways');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment