wc_create_order_note( int $order_id, string $note, bool $is_customer_note = false, bool $added_by_user = false )

Create an order note.


Description Description


Parameters Parameters

$order_id

(Required) Order ID.

$note

(Required) Note to add.

$is_customer_note

(Optional) If is a costumer note.

Default value: false

$added_by_user

(Optional) If note is create by an user.

Default value: false


Top ↑

Return Return

(int|WP_Error) Integer when created or WP_Error when found an error.


Top ↑

Source Source

File: includes/wc-order-functions.php

function wc_create_order_note( $order_id, $note, $is_customer_note = false, $added_by_user = false ) {
	$order = wc_get_order( $order_id );

	if ( ! $order ) {
		return new WP_Error( 'invalid_order_id', __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 400 ) );
	}

	return $order->add_order_note( $note, (int) $is_customer_note, $added_by_user );
}

Top ↑

Changelog Changelog

Changelog
Version Description
3.2.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.