Custom Order Action in WooCommerce

I am trying to add a custom order action on the WooCommerce order page.

I want to add two new parameters in a bulk order operation. Unpacking in WooCommerce.

  • Mark refund
  • Mark on Hold

Any help in this regard is much appreciated.

+6
source share
1 answer

To this end, two parts can be solved.

The first part is to get the custom action "Order" in the metaboc of a separate order page. I tried to do the same thing, but did not find anything specific 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 Basic Operations drop-down list on the Orders main page. Skyverge has a great tutorial on this:

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

The only thing you will need to pay attention to is using the correct post_type . For WooCommerce orders, you will need to use this instead of the first example in this 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 } } 

Please note that shop_order replaces the message to check the condition for which a bulk action has post_type added to post_type .

But basically, @brasofilo is correct - for the most part, WooCommerce uses standard WordPress structures, post_type mechanisms post_type and taxonomies. The process is the same for adding a bulk action to the Orders page, as on the Messages page.

However, you are right about the custom order actions on a separate Orders page - this is only WooCommerce, and you will need to refer to the first guide on how to solve this part.

+6
source

Source: https://habr.com/ru/post/970183/


All Articles