【问题标题】:Woocommerce - Display total amount of orders in admin panelWoocommerce - 在管理面板中显示订单总量
【发布时间】:2022-05-21 02:00:09
【问题描述】:

我需要在 Woocommerce 管理订单表中显示订单总量(我的意思是所有页面)但我找不到任何操作或挂钩。有没有办法做到这一点?你可以在下面的图片中看到我想要的。谢谢。

【问题讨论】:

  • @LoicTheAztec 我同意你的观点,但我正在寻找这样做的钩子,这是尝试的起点:) 我已经在互联网上搜索了很多,但我不能找到任何东西。
  • 这是关于 Wordpress 自定义帖子类型页面列表(“shop_order”帖子类型),所以在 WooCommerce 中没有钩子,我从未见过你之前问过的东西。您应该在 Wordpress Development (StackExchange) 中搜索帖子或自定义帖子页面列表...此管理订单列表页面由 this files 和 WordPress 管理。
  • @LoicTheAztec 你有这个问题的更新吗?我也在寻找解决方案。谢谢

标签: woocommerce hook


【解决方案1】:

这正是我们所需要的,并提出了一个运行良好的简单 JS 解决方案:

//ADD Total for current page on Admin Orders Page in column "total" header
add_action( 'admin_footer', 'ATW_order_total_admin_footer_tracking_js' );
function ATW_order_total_admin_footer_tracking_js() {
    global $pagenow;
    if ( $pagenow === 'edit.php' && isset($_GET['post_type']) && 'shop_order' === $_GET['post_type'] ) :
    ?>
    <script type="text/javascript">
    jQuery( function($){
        var total_total = 0.00;
        jQuery( "td.order_total.column-order_total > span" ).each(function( index ) {
            var tt = parseFloat(jQuery(this).text().replace("$","").replace(",",""));
            total_total=total_total+tt;
        });
        total_total = total_total.toFixed(2);
        jQuery('table > tfoot > tr > th.manage-column.column-order_total').append(" $"+total_total);
        jQuery('table > thead > tr > th.manage-column.column-order_total').append(" $"+total_total);
    });
    </script>
    <?php
    endif;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-16
    • 2012-07-18
    • 2017-07-22
    • 1970-01-01
    • 2018-08-08
    • 2020-12-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多