The following will display last admin order note to my account view orders pages:
add_filter( 'woocommerce_get_order_item_totals', 'account_view_order_last_order_note', 10, 3 );
function account_view_order_last_order_note( $total_rows, $order, $tax_display ){
// For "completed" orders on my account view order pages
if( $order->has_status('completed') && is_wc_endpoint_url( 'view-order' ) ){
// Get last order note
$latest_notes = wc_get_order_notes( array(
'order_id' => $order->get_id(),
'limit' => 1,
'orderby' => 'date_created_gmt',
) );
$latest_note = current( $latest_notes );
if ( isset( $latest_note->content ) ) {
// Add a new row for tracking
$total_rows['order_tracking'] = array(
'label' => __('Tracking:','woocommerce'),
'value' => $latest_note->content
);
}
}
return $total_rows;
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…