Skip to main content
Print

Payment methods that collect on delivery

By default, only WooCommerce’s own cash on delivery method is held as pending at Processing. This article shows how a developer can add other payment methods that collect the money on delivery.

The filter

hrcr_cod_payment_methods filters the list of payment method IDs treated as cash on delivery. It receives one argument, the list, which starts as array( 'cod' ), the ID of WooCommerce’s own method, and returns the new list.

add_filter( 'hrcr_cod_payment_methods', function ( $methods ) {
	$methods[] = 'my_delivery_gateway';
	return $methods;
} );

Put the code in a small custom plugin or in your child theme’s functions.php file.

How the list is used

  • An order paid with a method on the list is held as pending while its status is Processing, and confirmed when it is Completed. See Order outcomes and the cancellation rate.
  • The hold applies only while Keep cash on delivery orders pending until they are Completed. is ticked under Affiliate Reports → Settings.
  • IDs are cleaned the way WordPress cleans keys, lowercase letters, digits, dashes and underscores, and duplicates are dropped. An empty list holds no method at all.

To find a payment method’s ID, export the Orders report as a CSV file: its Payment method column holds the ID of each order’s method.

Warning: Outcomes are worked out each time a report is read, so adding a method changes past orders too. An order at Processing that you already paid commission on becomes pending, and its commission appears as an adjustment on the affiliate’s statement. See When a paid order changes.

Table of Contents