This is a cool function you can apply to any payment gateways for any order threshold. for example, you may want to disable bank transfers if orders are below $10, or disable PayPal payments if orders are above a certain cart total. Here’s what I did.

Disable PayPal based on Cart Total

PHP Snippet: Disable PayPal payment gateway on WooCommerce orders above $100


/**
 * @snippet       Disable PayPal Based on Cart Total - WooCommerce
 * @how-to        Get CustomizeWoo.com FREE
 * @sourcecode    https://businessbloomer.com/?p=377
 * @author        Rodolfo Melogli
 * @testedwith    WooCommerce 3.5.6
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

add_filter( 'woocommerce_available_payment_gateways', 'bbloomer_disable_paypal_above_100' );

function bbloomer_disable_paypal_above_100( $available_gateways ) {
$maximum = 100;
if ( WC()->cart->total > $maximum ) {
unset( $available_gateways['paypal'] );
}
return $available_gateways;
}

Is There a WooCommerce “Payment Gateways by Cart Total” Plugin?

If you don’t feel 100% confident with coding, I decided to look for a reliable plugin that achieves the same result of this snippet (and more).

In this case, I found the WooCommerce Conditional Payment Gateways plugin to be the most complete when you need to enable/disable payment gateways based on certain criteria. You can create unlimited “rules” and use, for example, cart totals, billing country, shipping country, user role and much more to define which payment gateway shows and which not.

But in case you don’t want to use plugins and wish to code (or wish to try that), then keep reading 🙂

Share:

Leave a Reply