yanknudtskov
12/10/2014 - 10:15 AM

Remove payment gateways based on the totalt amount in the WooCommerce cart.

Remove payment gateways based on the totalt amount in the WooCommerce cart.

<?php 

add_filter('woocommerce_available_payment_gateways', 'va_filter_gateways', 1);

function va_filter_gateways($gateways) {
	global $woocommerce;
	
	// This line should be changed to reflect the name of the payment gateway you want to remove
	$payment_method_name = 'paypal'; // Could be bacs, cheque, paypal, epay_dk, etc.
	
	// The limit for the cart before we remove the specified gateway
	$cart_total_limit = 5000;

	if($woocommerce->cart->total > $cart_total_limit)
	{
		unset($gateways[$payment_method_name]);
	}

	return $gateways;
}

?>