Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

Cash on delivery only up to €300

Cash on delivery disappears from the payment methods when the order total is above the amount you set.

  • Type PHP
  • Runs Everywhere (runs as WordPress loads)
  • Needs WooCommerce
  • Category WooCommerce
  • Tested with WordPress 7.1, WooCommerce 11.1

Before you switch it on: Set $maximum to the highest order total you accept cash on delivery for.

It arrives switched off, even when you install its whole pack with "Switch on after installing".

PHP
<?php

add_filter(
	'woocommerce_available_payment_gateways',
	static function ( $gateways ) {
		$maximum = 300;
		if ( is_admin() || ! WC()->cart ) {
			return $gateways;
		}
		if ( isset( $gateways['cod'] ) && (float) WC()->cart->get_total( 'edit' ) > $maximum ) {
			unset( $gateways['cod'] );
		}
		return $gateways;
	}
);

In these packs

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.