0

I am currently working on a wordpress/woocommerce project. At the backend, when the user clicks on woocommerce/orders menu, it will display all available order details. In order this table, there are several fields/columns (such as order, ship to, date, total, actions).

Under actions field, there are two buttons (order status and view). I want to add another button under this field. So, is there any code available that can be placed to functions.php to solve this problem.

Thank you.

1

@mmm thanks for that code, I didnt know this filter yet. Do you know if it is also possible to add a tooltip that way?

Anyway, I have a different solution to add a new button to this column, and also want to post it:

add_action( 'woocommerce_admin_order_actions_end', 'add_content_to_wcactions_column' );
function add_content_to_wcactions_column() {

    // create some tooltip text to show on hover
    $tooltip = __('Some tooltip text here.', 'textdomain');

    // create a button label
    $label = __('Label', 'textdomain');

    echo '<a class="button tips custom-class" href="#" data-tip="'.$tooltip.'">'.$label.'</a>';
}

Just replace the tooltip and label text and add your url in the link.


I tested the above code on an empty installation and this is what I get:
enter image description here

  • Hi @LWS_Mo, I want to get a button under the "actions" column of the Order table of WooCommerce admin section (which we access by Woocommerce/Orders menu). Unfortunately no button is displayed at the desired location. If u need any other info please tell. thanx. – Arnab Chatterjee Jan 19 '18 at 13:18
  • @ArnabChatterjee yes, I think I know what you want. I just tested this code in a fresh/empty install, and it is working for me without a problem. I also added a screenshot to the answer. – LWS-Mo Jan 19 '18 at 13:38
  • thank u for giving ur time. yes I absolutely want this. but why is it not working in my case ? I placed that code in the functions.php of the child theme. There is no other code in this file. so, where's the problem ?? – Arnab Chatterjee Jan 19 '18 at 13:46
  • Yeah thats strange. I tested this in an empty installation with just WooCommerce and the code I wrote. The code should work in your functions.php. Is the code from mmm working for you, because this code also works (I tested his code too), just copy it into functions.php. Try to add the code without editing it first, if it is still not working, maybe try to deactivate all other plugins. – LWS-Mo Jan 19 '18 at 14:08
  • Yes I guess ur code may be workable, but unfortunately this is not working with my site. Can it be happen due to conflictions of other plugins ? or anything else ? – Arnab Chatterjee Jan 19 '18 at 14:17
0

to add a action in this row, you can try this code :

add_filter("woocommerce_admin_order_actions", function ($actions, $the_order) {

    $actions[] = [
        "action" => "actionCode",
        "url" => admin_url("?page=myPage"),
        "name" => "New link",
    ];


    return $actions;

}, 10, 2);
  • Will I include post_type=shop_order in the ?page=myPage area ?? thank you – Arnab Chatterjee Jan 19 '18 at 13:06
  • Hi @mmm, I want to get a button under the "actions" column of the Order table of WooCommerce admin section (which we access by Woocommerce/Orders menu). Unfortunately no button is displayed at the desired location. If u need any other info please tell. thanx. – Arnab Chatterjee Jan 19 '18 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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