Display Customer order comments (customer note) in Woocommerce

Nick picture Nick · Nov 26, 2014 · Viewed 26.1k times · Source

I have a little problem when I try to display woocommerce customer order comments (not the notes, but the comments that a customer can add during the checkout process).

(I'm going to add just the relative lines for this problem, as other woocommerce data is correctly displayed so it shouldn't be a setup problem).

What I've tried so far is this:

$notes = $order->get_customer_order_notes(); //This line returns an Array[]

Inside that array, this is the field that I think I need, as it contains my order comment:

$notes
  0={stdClass} 38
    post_excerpt = "test"

and so what I did is trying to display this value like this:

echo "Order Notes: " . $notes->post_excerpt

but unfortunately the result is empty.

What am I doing wrong? Many thanks

Answer

Nick picture Nick · Nov 26, 2014

Ok, after some time spent on trying, I finally find out that the right way to display the customer checkout comment is selecting $order->customer_message; and set this value as variable.