Custom Order Action in WooCommerce

I am trying to add Custom Order Action in WooCommerce Orders Page.

I want to add two new options in Bulk Order Actions Dropdown in WooCommerce

Read More
  1. Mark Refunded
  2. Mark On- Hold

Any help in this regard is highly appreciated.

Related posts

Leave a Reply

1 comment

  1. There are two parts to solve with this objective.

    The first part is to get a custom Order Action in the metabox of the individual Orders Page. I was trying to accomplish the same thing, but didn’t find anything definitive on it, so I created a tutorial here:

    http://neversettle.it/add-custom-order-action-woocommerce/

    The second part is to add a custom order action in the Bulk Actions drop-down of the main Orders page. Skyverge has an excellent tutorial on that here:

    http://www.skyverge.com/blog/add-custom-bulk-action/

    The only specific thing you will need to take note of is to use the correct post_type. For WooCommerce orders you will need to use this in place of the first example on that tutorial:

    add_action('admin_footer-edit.php', 'custom_bulk_admin_footer');
    
    function custom_bulk_admin_footer() {
    
        global $post_type;
    
        if($post_type == 'shop_order') {
        ?>
        <script type="text/javascript">
            jQuery(document).ready(function() {
                jQuery('<option>').val('export').text('<?php _e('Export')?>').appendTo("select[name='action']");
                jQuery('<option>').val('export').text('<?php _e('Export')?>').appendTo("select[name='action2']");
            });
        </script>
        <?php
        }
    }
    

    Notice the shop_order replaces the post for the condition checking which post_type to add the bulk actions to.

    But fundamentally, @brasofilo is correct – for the most part WooCommerce uses standard WordPress structures, post_type mechanisms, and taxonomies. The process is the same for adding a bulk action to the Orders page as it is to the Posts page.

    However, you are correct about the custom Order Actions on the individual Orders page – that is WooCommerce only and you’ll need to reference the first tutorial on how to solve that part.