How to unset WooCommerce order actions

If you’ve ever gotten down to business with WooCommerce, you’ll know how flexible that beast can get. Of course, the flip side to that is how gnarly things can get in there as well but I guess that’s the double-edged sword we live with when building complicated things out of WordPress.

One little handy point of extension is the ability to customise the available order actions when editing an order. If you’re not entirely sure what I’m talking about, here’s a screenshot:

The WooCommerce order actions meta box

This ships with a bunch of order actions by default and they’re all relatively handy but it’s not uncommon for me to come up against situations where I don’t need them all there.

How to remove the default WooCommerce order actions…

It’s a really simple little snippet as you can see below. The filter receives an associative array of action/title pairs so you can unset them as per this example or you could even rename them if you want to.

<?php
add_filter( 'woocommerce_order_actions', function ( $actions ) {
// Unset whatever actions you don't need available in the
// WooCommerce order edit screen.
unset( $actions['send_order_details_admin'] );
unset( $actions['send_order_details'] );
unset( $actions['regenerate_download_permissions'] );
return $actions;
}, 20 );

Need a website? Let's talk.

From website design & SEO through to custom WordPress plugin development. I transform ideas into dynamic, engaging, and high-performing solutions.
Subscribe to get the latest insights & updates in the world of web and how it impacts your business and website.
© 2024 Phil Kurth  |  All rights reserved.