在“管理”列上显示付款单注释

时间:2018-06-29 16:51:01

标签: wordpress woocommerce

我正在使用以下代码段,但它只能显示最新的订单记录,而不能显示订单中的付款记录。如何显示付款通知单,而不显示其余的付款单?感谢您的帮助。谢谢!

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>';
            }
        }
    }
}

0 个答案:

没有答案
相关问题