{lang: 'hu'}

It took a while to figure it out how to get all the comments of an order, but finally I succeeded. So my first try looked like this:


function get_all_order_comments($order_id) {
	$args = array(
		'post_id' => $order_id,
		'approve' => 'approve',
		'type' => ''
	);

	return get_comments($args);
}

Unfortunately it didn’t work, because – as it turned out – the woocommerce runs a filter as you ask for the comments. (my guess is if the comments are allowed at a product and the template is able to show the comments, these private informations shouldn’t be listed) In order to make it work, you should remove the filter, and after getting the result, register the filter again. Which looks something like this:


function get_all_order_comments($order_id) {
	remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ) );

	$comments = get_comments( array(
		'post_id' => $order_id,
		'approve' => 'approve',
		'type' => ''
	) );

	add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ) );

	return $comments;
}