0

I wanna remove the functionality of when you click on a order row in Orders in Admin, you will be sent to the edit page for that order.

I know it's added with jQuery in a js-file in the WooCommerce plugin. I have located the actual code:

/**
 * Click a row.
 */
WCOrdersTable.prototype.onRowClick = function( e ) {
    if ( $( e.target ).filter( 'a, a *, .no-link, .no-link *, button, button *' ).length ) {
        return true;
    }

    if ( window.getSelection && window.getSelection().toString().length ) {
        return true;
    }

    var $row = $( this ).closest( 'tr' ),
        href = $row.find( 'a.order-view' ).attr( 'href' );

    if ( href && href.length ) {
        e.preventDefault();

        if ( e.metaKey || e.ctrlKey ) {
            window.open( href, '_blank' );
        } else {
            window.location = href;
        }
    }
};

But I don't wanna change any code in the plugin. And there aren't js hooks or any php hook that can control that part of code.

So I guess the option is to add the no-link class to the columns in the list? How do I do that? I can't find anything about how to do that.

1

Based on class-wc-admin-list-table-orders.php (order column on line 173) there doesn't seem to be a filter to change the markup.

To circumvent this, perhaps you could add a js/jQuery script, to admin_footer or with admin_enqueue_scripts, which either adds the necessary class(es), removes href or changes it to #, or with some event delegation wizardry have your own click event fire first and prevent the WCOrdersTable window.location from happening.

  • You are right. Maybe that's the options there is. And if I create other elements in a column, with the no-link class, that element wouldn't be "linked". So maybe that's what I should do instead. – Peter Westerlund May 24 at 18:17

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.