简体   繁体   English

在WooCommerce 3.3的管理订单列表中显示回购订单注释

[英]Display back Order Notes in Admin orders list on WooCommerce 3.3

Is there any hooks or options to display order notes in WooCommerce order page in back end ? 后端的WooCommerce订单页面中是否有任何挂钩或选项显示订单记录? I have tried the following code and managed to add a column. 我试过下面的代码并设法添加一列。

function wc_new_order_column( $columns ) {
    $columns['my_column'] = 'My column';
    return $columns;
}
add_filter( 'manage_edit-shop_order_columns', 'wc_new_order_column' );

I am stuck in adding order notes 我被困在添加订购单中

The following will enable back the display of Order Notes in WooCommerce 3.3+ admin orders list: 以下将启用WooCommerce 3.3+管理员订单列表中的订单注释显示:

add_filter( 'manage_edit-shop_order_columns', 'custom_shop_order_column', 90 );
function custom_shop_order_column( $columns )
{
    $ordered_columns = array();

    foreach( $columns as $key => $column ){
        $ordered_columns[$key] = $column;
        if( 'order_date' == $key ){
            $ordered_columns['order_notes'] = __( 'Notes', 'woocommerce');
        }
    }

    return $ordered_columns;
}

add_action( 'manage_shop_order_posts_custom_column' , 'custom_shop_order_list_column_content', 10, 1 );
function custom_shop_order_list_column_content( $column )
{
    global $post, $the_order;

    $customer_note = $post->post_excerpt;

    if ( $column == 'order_notes' ) {

        if ( $the_order->get_customer_note() ) {
            echo '<span class="note-on customer tips" data-tip="' . wc_sanitize_tooltip( $the_order->get_customer_note() ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
        }

        if ( $post->comment_count ) {

            $latest_notes = wc_get_order_notes( array(
                'order_id' => $post->ID,
                'limit'    => 1,
                'orderby'  => 'date_created_gmt',
            ) );

            $latest_note = current( $latest_notes );

            if ( isset( $latest_note->content ) && 1 == $post->comment_count ) {
                echo '<span class="note-on tips" data-tip="' . wc_sanitize_tooltip( $latest_note->content ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
            } elseif ( isset( $latest_note->content ) ) {
                // translators: %d: notes count
                echo '<span class="note-on tips" data-tip="' . wc_sanitize_tooltip( $latest_note->content . '<br/><small style="display:block">' . sprintf( _n( 'Plus %d other note', 'Plus %d other notes', ( $post->comment_count - 1 ), 'woocommerce' ), $post->comment_count - 1 ) . '</small>' ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
            } else {
                // translators: %d: notes count
                echo '<span class="note-on tips" data-tip="' . wc_sanitize_tooltip( sprintf( _n( '%d note', '%d notes', $post->comment_count, 'woocommerce' ), $post->comment_count ) ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
            }
        }
    }
}

// Set Here the WooCommerce icon for your action button
add_action( 'admin_head', 'add_custom_order_status_actions_button_css' );
function add_custom_order_status_actions_button_css() {
    echo '<style>
    td.order_notes > .note-on { display: inline-block !important;}
    span.note-on.customer { margin-right: 4px !important;}
    span.note-on.customer::after { font-family: woocommerce !important; content: "\e026" !important;}
    </style>';
}

Code goes in function.php file of your active child theme (or theme). 代码进入您的活动子主题(或主题)的function.php文件中。

Tested and works. 经过测试和工作。

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Woocommerce管理员“订单”列表上的自定义列中显示来自订单注释的交易ID - Display the transaction ID from order notes in a custom column on Woocommerce admin Orders list WooCommerce 管理员订单列表自定义列,其中包含发送给客户的订单备注 - WooCommerce admin orders list custom column with order notes sent to customer 在 WooCommerce 管理员订单列表的自定义列中显示私人和客户管理员注释 - Display private and customer admin notes in a custom column on WooCommerce admin orders list 在 WooCommerce admin Orders List 列显示复合订单数据 - Display composite order data in WooCommerce admin Orders List column 在 WooCommerce 我的帐户订单列表中添加发送给客户的管理员订单备注 - Add Admin order notes sent to customer in WooCommerce My Account Orders list 在woocommerce 3.3的管理员订单列表中添加列 - Add columns in admin order list on woocommerce 3.3 在 WooCommerce 管理订单列表中显示已使用的优惠券 - Display used coupons on WooCommerce admin orders list 在 Woocommerce 管理订单列表中显示具有“全部”自定义状态的订单 - Display orders with a custom status for “all” in Woocommerce admin orders list 仅在 WooCommerce 管理订单上显示自定义订单项元数据 - Display custom order item metadata only on WooCommerce admin orders 将客户email和“订单”栏中的电话添加到Woocommerce的管理订单列表中 - Add customer email and phone in "Order" column to admin orders list on Woocommerce
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM