0

I have a woocommerce shop, and I want to be able show orders where a custom field has a value of today.

I realized that it can be done by going to a certain url, since updating the HTTP query string will get the job done. I'm thinking of something likes this: 'domain.com/wp-admin/edit.php?order_by=abc&date=DATE_HERE&somethingelse'

So how can I put an html <a>-element on the woocommerce orders page, and how can I update the href automatically using javascript? Which php action hooks should I use?

enter image description here

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
user2947684
  • 31
  • 1
  • 7

1 Answers1

1

The following code will add a custom button, based on your attached image. Why should the href update be done via javascript and not with php?

// Add action button
function my_manage_posts_extra_tablenav( $which ) {
    global $pagenow, $typenow;

    if ( $typenow === 'shop_order' && $pagenow === 'edit.php' && $which === 'top' ) {
        ?>
        <div class="alignleft actions custom">
            <button type="submit" name="custom" style="height:32px;" class="button" value="">
            <?php echo __( 'Custom', 'woocommerce' ); ?>
            </button>
        </div>
        <?php
    }
}
add_action( 'manage_posts_extra_tablenav', 'my_manage_posts_extra_tablenav', 20, 1 );
7uc1f3r
  • 28,449
  • 17
  • 32
  • 50
  • Thank you! Wanted to use js, because there was some logic that I didn't want to write using php - but that could of course be used too – user2947684 Apr 02 '20 at 18:36