WooCommerce: How to Disable PayPal on Orders Above $100

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        businessbloomer.com/woocommerce-customization
 * @sourcecode    https://businessbloomer.com/?p=377
 * @author        Rodolfo Melogli, Business Bloomer
 * @testedwith    WooCommerce 3.5.6
 * @community     https://businessbloomer.com/club/
 */

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 πŸ™‚

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

30 thoughts on “WooCommerce: How to Disable PayPal on Orders Above $100

  1. Hmm, not sure this is still working. I’m using WP 5.9 and PHP 8.0 and it doesn’t appear to.

    1. Screenshot of the checkout please?

  2. Unfortunately this does not work for the Klarna plugin! Any idea why?

    Thanks!

    1. Probably it needs customization

  3. HI, thank you.
    I’m trying to disable “bacs” payment lower 100€.

    I tried to modify:
    – changed “maximum” > to “minimum”
    – changed “paypal” > to “bacs”
    But doesn’t works πŸ™

    1. nevermind, i fix. thank you the same

  4. changing payment gateway to ‘paypal_express’ removes it as a gateway option, but it doesn’t disable the express checkout buttons.

    1. Hi Asim, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  5. Hi, thanks for the tutorials, very much helpful. We used this one as well, but we need one more thing which is slightly like this. Actually we have local delievery only, so we have minimum order amount for specific postcodes. And we have coded to throw custom error message at checkout page when a user try to click place order button with less amount than the minimum order amount for his postcode. This works fine for us for cod payments. But when it comes to Paypal Express checkout, the Paypal login modal opens before the validation. So the custom error message is not displaying, only the red alert mark is appearing.
    I am using “woocommerce_checkout_process” hook to display wc notice errors.

    1. Tom, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  6. Hello Rodolfo,

    I’m using this function for disabling COD gateway. It works great, thanks! But is there a way to “grey out” payment method instead of hiding it completely? This way we can show our customers that they can stil use this payment method if they decrease their cart total.

    1. Hi Deniz, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  7. Hey Rodolfo, Thanks for the amazing snippet. I would like to know If I change it from Paypal to COD and $100 to 10,000 rupees. Will it work? I have added the code below for your reference.

    add_filter( 'woocommerce_available_payment_gateways', 'bbloomer_disable_cod_above_10000' );
     
    function bbloomer_disable_paypal_above_10000( $available_gateways ) {
    $maximum = 10000;
    if ( WC()->cart->total > $maximum ) {
    unset( $available_gateways['cod'] );
    }
    return $available_gateways;
    }
    

    .

    1. I have tested it with COD on staging and it worked. Great.

      1. Awesome!

  8. So great ! Every time I am looking for a function on google I find your website ! Thanks again.

    1. Awesome!

  9. Thank you for this! I’m trying to do something very similar, with product weight. I’d like the PayPal Gateway to be disabled on individual product pages (single product checkout) AND on the checkout page for all products that weigh 150lbs and over.

    Is it possible for me to slightly tweak this code for that to happen?

    I appreciate it!
    Rob

    1. Hello Rob, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R

  10. Hi, great code.
    I want to use it on the “pay_for_order” page also.
    Can it be modified so it can be used also there πŸ™‚
    (there is no cart total then)
    Thanks Paul

    1. Hello Paul, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R

  11. Hi,

    Since I changed from the standard paypal gateway to the WooCommerce PayPal Express Checkout Gateway this snippets is not working anymore. Any Idea how to fix it?

    Thank you.

    1. Hello Federico, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  12. It works like a charm

  13. Thank you very much for sharing this.

    1. You’re very welcome Raul!

  14. How would you modify the code above to disable paypal express checkout? This is super awesome if I knew that.

    Thanks for any help.

    1. Hey Stephen, thanks for your comment! I suppose it depends on the plugin you’re using – which one is it? πŸ™‚

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *