WordPress filter hook
woocommerce_cancel_unpaid_order
Defined by WooCommerce and fired by 5 plugins in total, running on 7M+ sites between them.
“Filters whether an unpaid order should be automatically cancelled.”
How to use woocommerce_cancel_unpaid_order
It's a filter: your callback receives the value and 1 more argument, and must return the (changed) value.
Add this to your theme's functions.php or a small custom plugin:
add_filter( 'woocommerce_cancel_unpaid_order', function( $value, $unpaid_order ) {
// Change $value here.
return $value;
}, 10, 2 );Argument names come from Multibanco, MB WAY, Credit card, Apple Pay, Google Pay, Payshop, and PIX (ifthenpay) for WooCommerce's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
5 plugins that fire woocommerce_cancel_unpaid_order
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
WooCommerce7+ million installs
apply_filters( 'woocommerce_cancel_unpaid_order', in_array( $order->get_created_via(), array( 'checkout', 'store-api' ), true ), $order )includes/wc-order-functions.php:1207 -
Multibanco, MB WAY, Credit card, Apple Pay, Google Pay, Payshop, and PIX (ifthenpay) for WooCommerce8,000+ installs
apply_filters( 'woocommerce_cancel_unpaid_order', 'checkout' === $unpaid_order->get_created_via(), $unpaid_order )class-wc-ifthen-webdados.php:2707 -
Checkout with Zelle on Woocommerce3,000+ installs
apply_filters( 'woocommerce_cancel_unpaid_order', in_array( $order->get_created_via(), array('checkout', 'store-api'), true ), $order )includes/class-wc_zelle_gateway.php:906 -
워드프레스 결제 심플페이900+ installs
apply_filters( 'woocommerce_cancel_unpaid_order', 'checkout' === $unpaid_order->get_created_via(), $unpaid_order )includes/class-pafw-cancel-unpaid-order.php:74 -
EasyTransac for WooCommerce50+ installs
apply_filters( 'woocommerce_cancel_unpaid_order', 'checkout' === $order->get_created_via(), $order )includes/Hooks/StockCancelHook.php:54
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.