Restrict Payment Methods based on Cart Total

In this tutorial I will show you how to disable WooCommerce payment gateways based on cart total without use of any plugin.

If you need some custom coding help with WooCommerce payment gateways or maybe you need to develop one – please feel free to contact me in both cases.

In the below example we are going to disable “Cash on Delivery” payment method if total amount in cart is more than 1000 (in shop currency) using woocommerce_available_payment_gateways filter hook.

add_filter( 'woocommerce_available_payment_gateways', 'rudr_turn_off_cod' );

function rudr_turn_off_cod( $available_gateways ) {
	if( is_admin() ) {
		return $available_gateways;
	// STEP 1: Get order/cart total
	if( is_wc_endpoint_url( 'order-pay' ) ) { // Pay for order page
		$order_id = wc_get_order_id_by_order_key( $_GET[ 'key' ] );
		$order = wc_get_order( $order_id );
		$order_total = $order->get_total();
	} else { // Cart/Checkout page
		$order_total = WC()->cart->get_total();
	// STEP 2: Disable payment gateway if order/cart total is more than 1000
	if ( $order_total > 1000 ) {
		unset( $available_gateways[ 'cod' ] ); // unset Cash on Delivery

	return $available_gateways;



Misha Rudrastyh

Misha Rudrastyh

Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.

Need some developer help? Contact me

Follow me on X