Created
August 11, 2016 01:09
-
-
Save bentasm1/764427ca73cbda9d107838f7598f11e7 to your computer and use it in GitHub Desktop.
WooCommerce Rotate between 5 payment gateways
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 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