/** * Displays customer/public order notes/comments. * * The function uses the `get_customer_order_notes()` method * and displays all customer/public order notes/comments ("Note to customer"), * each on a new line. Not to confuse with the `get_customer_note()` method, * which returns "Customer provided note", i.e., the "Order notes (optional)" * checkout field value ("Notes about your order, e.g. special notes for delivery"). * * @see https://wpcodebook.com/woocommerce-display-customer-order-notes/ * @see https://woocommerce.github.io/code-reference/classes/WC-Order.html#method_get_customer_order_notes */ function wpcodebook_customer_order_notes( $order_id ) { if ( ! ( $order = wc_get_order( $order_id ) ) ) { return false; } $notes = $order->get_customer_order_notes(); $notes = wp_list_pluck( $notes, 'comment_content' ); $notes = implode( '<br>', $notes ); return $notes; }