• Resolved neilgee

    (@neilgee)


    Hi,
    Looking to export Private Notes only from WooCommerce Orders – seen this solution but that also outputs Order status changes:

    "Order status changed from Pending payment to Processing.
    This is a private note added
    Order status changed from Processing to Completed."

    How can the referred code be changed just to show Private Notes Only:

    add_filter('woe_get_order_value_private_notes',function ($value, $order,$fieldname) {
    	remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ) );
    	$args  = array(
    		'post_id' => $order->get_id(),
    		'approve' => 'approve',
    		'type'    => 'order_note',
    		'orderby' => 'comment_ID',
    		'order'   => 'ASC',
    		);
    	$notes = get_comments( $args );
    	add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' )  );
    
    	$lines = array();
    	foreach($notes as $note) {
    		if($note->comment_author!='WooCommerce' AND !get_comment_meta( $note->comment_ID, 'is_customer_note', true ) ) 
    			$lines[] = $note->comment_content;
    	}
    	return join("\n",$lines);
    },10,3);

    Many Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author algol.plus

    (@algolplus)

    hello

    you can modify this line
    if($note->comment_author!='WooCommerce' AND !get_comment_meta( $note->comment_ID, 'is_customer_note', true ) )

    just replace it with
    if($note->comment_author!='WooCommerce' AND !get_comment_meta( $note->comment_ID, 'is_customer_note', true ) AND strpos($note->comment_content,"Order status changed")===false )

    Thread Starter neilgee

    (@neilgee)

    Perfect – thanks!

    Plugin Author algol.plus

    (@algolplus)

    you’re welcome

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Private Notes Only’ is closed to new replies.