首页 > 解决方案 > Woocommerce 订单列表中的私人笔记

问题描述

我们在私人笔记中添加我们自己的生产编号,如果我们可以在新列下的订单列表中显示这些私人笔记,那将非常方便,在互联网上搜索但没有一个代码有效。

非常感谢!

标签: wordpresswoocommerce

解决方案


尝试在 function.php 文件中添加此代码段:

add_action( 'wpo_wcol_custom_row', 'wpo_wcol_order_notes', 10, 1 );
function wpo_wcol_order_notes ( $order_id ) {
    $notes = wc_get_order_notes( array(
        'order_id' => $order_id,
        'type'     => 'customer', // use 'internal' for admin and system notes, empty for all
    ) );

    if ( $notes ) {
        foreach( $notes as $key => $note ) {
            // system notes can be identified by $note->added_by == 'system'
            printf( '<div class="note_content">%s</div>', wpautop( wptexturize( wp_kses_post( make_clickable( $note->content ) ) ) ) );
        }
    }
}

推荐阅读