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        Watch tutorial @ https://businessbloomer.com/?p=19055
 * @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 ๐Ÿ™‚

Where to add this code?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such delicate files - if you need more guidance, please take a look at my free WooCommerce Customization video tutorial.

Does this snippet still work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free videos, tutorials and tips!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP
  • woocommerce-customize-shop-page-PHP
  • woocommerce-advanced-customization
  • how-to-edit-woocommerce-cart
  • woocommerce-customize-checkout-page-PHP
  • woocommerce-email-customization
  • woocommerce-conditional-logic

Rodolfo Melogli

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as a 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.

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

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

    1. Awesome!

  2. 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

  3. 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

  4. 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

  5. It works like a charm

    1. Brilliant ๐Ÿ™‚

  6. Thank you very much for sharing this.

    1. You’re very welcome Raul!

  7. 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? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between: [php]code_here[/php]. Failure to complying with this (as well as going off topic) will result in comment deletion. You should expect a reply in about a week - this is a popular blog but I need to get paid work done first. Please consider joining #BloomerArmada to ask me 1-to-1 WooCommerce questions. Thank you :)

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.