I'm trying to disable the bacs gateway if the customers cart total is over £500.
I have this code here which I've placed into my storefront functions.php file
add_filter('woocommerce_available_payment_gateways','filter_gateways',1);
function filter_gateways($gateways){
global $woocommerce;
$min_cart_total = 500;
$cart_total = ($woocommerce->cart->get_cart_total());
$cart_total = ereg_replace("[^0-9]", "", $cart_total)/100;
if ($cart_total > $min_cart_total){
unset($gateways['bacs']);
}
return $gateways;
}
But the options for bacs still shows up at the end even if my cart total is £250 for example.
Is there anything I'm doing wrong here?