WordPress filter hook

woocommerce_valid_order_statuses_for_cancel

Defined by WooCommerce and fired by 25 plugins in total, running on 7.1M+ sites between them.

“Filter valid order statuses for cancel.”

How to use woocommerce_valid_order_statuses_for_cancel

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:

functions.php
add_filter( 'woocommerce_valid_order_statuses_for_cancel', function( $value, $order ) {
	// Change $value here.
	return $value;
}, 10, 2 );

Argument names come from Donation Platform for WooCommerce: Fundraising & Donation Management's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

25 plugins that fire woocommerce_valid_order_statuses_for_cancel

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. WooCommerce icon WooCommerce7+ million installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( OrderStatus::PENDING, OrderStatus::FAILED ), $order ) includes/class-wc-form-handler.php:958
  2. Dokan: AI Powered WooCommerce Multivendor Marketplace Solution icon Dokan: AI Powered WooCommerce Multivendor Marketplace Solution30,000+ installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', [ 'pending', 'failed' ], $order ) includes/ReverseWithdrawal/Helper.php:875
  3. Donation Platform for WooCommerce: Fundraising & Donation Management icon Donation Platform for WooCommerce: Fundraising & Donation Management6,000+ installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) includes/integrations/woocommerce-subscriptions/templates/myaccount/related-orders.php:82
  4. YITH WooCommerce Subscription icon YITH WooCommerce Subscription6,000+ installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) templates/myaccount/view-subscription.php:254
  5. Youzify icon Youzify4,000+ installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) includes/public/templates/members/single/woocommerce/myaccount/related-orders.php:63
  6. Tamara Checkout icon Tamara Checkout3,000+ installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', ['pending', 'failed'], $wcOrder ) src/TamaraCheckout.php:1400
  7. Flexible Subscriptions icon Flexible Subscriptions1,000+ installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', [ 'pending', 'failed' ], $order ) templates/myaccount/payment-requests.php:89
  8. PayZen for WooCommerce icon PayZen for WooCommerce600+ installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array('pending', 'failed'), $order ) class-wc-gateway-payzen.php:1541
  9. Paysera Smart Checkout for WooCommerce icon Paysera Smart Checkout for WooCommerce500+ installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', self::VALID_ORDER_STATUSES_FOR_CANCEL, $order ) src/Service/Provider/WooCommerceOrderProvider.php:437
  10. Payment Gateway for Bachs for WooCommerce icon Payment Gateway for Bachs for WooCommerce50+ installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) includes/class-pgbw-gateway.php:994
  11. Opproval icon Opproval40+ installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) order-approval.php:187
  12. Subscriptions & Recurring Payments for WooCommerce icon Subscriptions & Recurring Payments for WooCommerce10+ installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) inc/renewal/class-awc-cart-early-renewal.php:348
  13. SkyHS icon SkyHS10+ installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) includes/early-renewal/class-skyhshoso-cart-early-renewal.php:286
  14. YeeSubscriptions icon YeeSubscriptions10+ installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array('pending', 'failed'), $order ) includes/frontend/class-yeekit-subscriptions-frontend-my-account.php:713
  15. Pay Now Direct SNAP icon Pay Now Direct SNAP10+ installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) includes/FrontEnd.php:903
  16. Lootly Loyalty & Rewards icon Lootly Loyalty & Rewards10+ installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', ['pending', 'failed'], $order ) classes/PendingCouponHold.php:118
  17. Thanh Toan The Cao Dien Thoai icon Thanh Toan The Cao Dien Thoai10+ installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) templates/my-orders.php:89
  18. iw profile icon iw profile10+ installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) template/logged-in/orders.php:58
  19. Elegant Profile for WooCommerce icon Elegant Profile for WooCommerceFewer than 10 installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) includes/class-epfw-forms.php:922
  20. Agent Adapt icon Agent AdaptFewer than 10 installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) includes/capabilities/class-agentadapt-orders.php:249
  21. Pre-Order for WooCommerce with Release Date & Countdown icon Pre-Order for WooCommerce with Release Date & CountdownFewer than 10 installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', [ 'pending', 'failed' ], $order ) templates/front/myaccount/preorder-list-template.php:153
  22. S2 Subscription for WooCommerce icon S2 Subscription for WooCommerceFewer than 10 installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', [ 'pending', 'failed' ], $order ) templates/myaccount/view-subscription.php:209
  23. Bachs Payment Gateway for WooCommerce icon Bachs Payment Gateway for WooCommerceFewer than 10 installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) includes/class-bachs-wc-gateway.php:1634
  24. Fiizy Pay Later Multi-lender Payment Gateway for WooCommerce icon Fiizy Pay Later Multi-lender Payment Gateway for WooCommerceFewer than 10 installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) src/Controller/Payment.php:72
  25. ShopCurator icon ShopCuratorFewer than 10 installs apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) src/Account/Cancellation.php:189

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.