I am using woocommerce_admin_order_actions hook to add an additional action like Invoice. But it is repeating many many times whereas others button are repeating once.

public function add_new_list_for_action($actions, $the_order) {

  if ( $the_order->has_status( array( 'processing' ) ) ) {
       $status = $_GET['status'];
       $order_id = method_exists($the_order, 'get_id') ? $the_order->get_id() : $the_order->id;
       $actions[] = ["action" => "invoice",
                     "url" => wp_nonce_url(admin_url('admin-ajax.php?action=wip_pdf_generator&status=invoice'.$status.'&order_id=' . $order_id), 'wip_pdf_generator'),
                     "name" => "Invoice"];
    return $actions;


add_filter( 'woocommerce_admin_order_actions', array($this, 'add_new_list_for_action'),1, 2);

2 Answers 2


Add this below code your current active theme functions.php file

add_filter( 'woocommerce_admin_order_actions', 'add_custom_order_status_actions_button', 100, 2 );
function add_custom_order_status_actions_button( $actions, $order ) {

    if ( $order->has_status( array( 'processing' ) ) ) {

        // The key slug defined for your action button
        $action_slug = 'invoice';
         $status = $_GET['status'];
         $order_id = method_exists($the_order, 'get_id') ? $the_order->get_id() : $the_order->id;
        // Set the action button
        $actions[$action_slug] = array(
            'url'       => wp_nonce_url(admin_url('admin-ajax.php?action=wip_pdf_generator&status=invoice'.$status.'&order_id=' . $order_id), 'wip_pdf_generator'),
            'name'      => __( 'Invoice', 'woocommerce' ),
            'action'    => $action_slug,
    return $actions;

add_action( 'admin_head', 'add_custom_order_status_actions_button_css' );
function add_custom_order_status_actions_button_css() {
    $action_slug = "invoice"; // The key slug defined for your action button

    echo '<style>.wc-action-button-'.$action_slug.'::after { font-family: woocommerce !important; content: "\e029" !important; }</style>';

enter image description here

  • I am making an extension plugin for woocommerce use.So I am using this hook in my plugin.
    – Rafiq
    Commented Aug 1, 2018 at 10:15
  • @Rafiq Yes fine with custom plugin also.
    – VinothRaja
    Commented Aug 1, 2018 at 10:22

Its a common error which you are facing, infect when you attached some code with WordPress action hock, that action hock called many time in loop so best practice which I have observed in such case it to attached the code with some conditional if/else statement which executes the code when conditions comes true. Right now in your case I have not any code to share but it will work if you know some specific condition in your code context.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.