最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

hooks - Remove Order List Row Link in WooCommerce Admin?

programmeradmin2浏览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.

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.

Share Improve this question asked May 21, 2019 at 21:37 Peter WesterlundPeter Westerlund 1,0775 gold badges14 silver badges31 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 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 can check here how to add no-link class into woocommerce order list row

orginal issue asked here https://github/woocommerce/woocommerce/issues/18704

orginal issue asked answer here https://github/woocommerce/woocommerce/pull/18708

发布评论

评论列表(0)

  1. 暂无评论