WooCommerce Code Reference

FulfillmentOrderNotes
in package

FulfillmentOrderNotes class.

Hooks into fulfillment lifecycle actions and adds filterable order notes for fulfillment state changes.

Tags
since
10.7.0

Table of Contents

add_fulfillment_created_note()  : void
Add an order note when a fulfillment is created.
add_fulfillment_deleted_note()  : void
Add an order note when a fulfillment is deleted.
add_fulfillment_updated_note()  : void
Add an order note when a fulfillment is updated.
add_order_fulfillment_status_changed_note()  : void
Add an order note when the order fulfillment status changes.
register()  : void
Register hooks for fulfillment order notes.
add_fulfillment_status_changed_note()  : void
Add a status change note for a fulfillment.
format_items()  : string
Format fulfillment items as a comma-separated string.
format_tracking()  : string
Format the tracking information from a fulfillment.
get_fulfillment_status_label()  : string
Get the display label for a fulfillment status key.
get_order_fulfillment_status_label()  : string
Get the display label for an order fulfillment status key.
normalize_note_message()  : string|null
Sanitize an order note message.

Methods

add_fulfillment_updated_note()

Add an order note when a fulfillment is updated.

public add_fulfillment_updated_note(Fulfillment $fulfillment[, array<string|int, mixed> $changes = array() ][, string $previous_status = 'unfulfilled' ]) : void

Only adds a note when tracked properties change (status, items, tracking number, tracking URL, shipping provider). If the status changed, a dedicated status change note is added instead.

Parameters
$fulfillment : Fulfillment

The fulfillment object (post-update).

$changes : array<string|int, mixed> = array()

Changes as returned by Fulfillment::get_changes() before save. Core data props at top level, meta under 'meta_data'.

$previous_status : string = 'unfulfilled'

The fulfillment status before the update.

Return values
void

add_order_fulfillment_status_changed_note()

Add an order note when the order fulfillment status changes.

public add_order_fulfillment_status_changed_note(WC_Order $order, string $old_status, string $new_status) : void

Called from FulfillmentsManager when the _fulfillment_status meta changes.

Parameters
$order : WC_Order

The order object.

$old_status : string

The previous fulfillment status.

$new_status : string

The new fulfillment status.

Return values
void

add_fulfillment_status_changed_note()

Add a status change note for a fulfillment.

private add_fulfillment_status_changed_note(Fulfillment $fulfillment, WC_Order $order, string $old_status, string $new_status) : void
Parameters
$fulfillment : Fulfillment

The fulfillment object.

$order : WC_Order

The order object.

$old_status : string

The previous status.

$new_status : string

The new status.

Return values
void

format_tracking()

Format the tracking information from a fulfillment.

private format_tracking(Fulfillment $fulfillment) : string

Includes the tracking number, shipping provider, and tracking URL when available.

Parameters
$fulfillment : Fulfillment

The fulfillment object.

Return values
stringThe formatted tracking information, or empty string if no tracking number is present.

get_fulfillment_status_label()

Get the display label for a fulfillment status key.

private get_fulfillment_status_label(string $status) : string
Parameters
$status : string

The fulfillment status key.

Return values
stringThe status label, or the key itself if no label is found.

get_order_fulfillment_status_label()

Get the display label for an order fulfillment status key.

private get_order_fulfillment_status_label(string $status) : string
Parameters
$status : string

The order fulfillment status key.

Return values
stringThe status label, or the key itself if no label is found.

normalize_note_message()

Sanitize an order note message.

private normalize_note_message(mixed $message) : string|null

Ensures the message is a string and strips any disallowed HTML tags.

Parameters
$message : mixed

The original message.

Return values
string|nullThe sanitized message, or null if the message is not valid.