# Disable a Payment Method Above an Order Total

> Hides a payment method such as cash on delivery or bank transfer when the order total goes above a limit you choose.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, payments, checkout, limits
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-gateway-max-amount/

## Code

```php
add_filter( 'woocommerce_available_payment_gateways', function ( $gateways ) {
    $gateway   = 'cod'; // Payment method ID.
    $max_total = 500;   // Hide it above this order total.

    if ( is_admin() || ! WC()->cart || ! isset( $gateways[ $gateway ] ) ) {
        return $gateways;
    }

    if ( (float) WC()->cart->get_total( 'edit' ) > $max_total ) {
        unset( $gateways[ $gateway ] );
    }

    return $gateways;
} );
```

## Notes

Set $gateway and $max_total. The check uses the cart total including shipping and tax.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Disable a Payment Method Above an Order Total" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
