Let Customers Cancel On-Hold Orders
Adds a Cancel button in My Account for orders that are on hold (for example unpaid bank transfers), not just pending ones.
Opens WPIDE on
Code
add_filter( 'woocommerce_valid_order_statuses_for_cancel', function ( $statuses ) {
$statuses[] = 'on-hold';
return array_unique( $statuses );
}, 10, 1 );
Notes
Cancelled orders restock their items automatically.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.