Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ewallz/a95aa02fb838b5c8b0be868d42c8dfdf to your computer and use it in GitHub Desktop.
Save ewallz/a95aa02fb838b5c8b0be868d42c8dfdf to your computer and use it in GitHub Desktop.
Remove payment gateways based on the totalt amount in the WooCommerce cart. #woocommerce #cart #gateways
<?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;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment