Automattic\WooCommerce\Admin\Features\Fulfillments
FulfillmentOrderNotes::add_order_fulfillment_status_changed_note
Add an order note when the order fulfillment status changes.
Called from FulfillmentsManager when the _fulfillment_status meta changes.
Method of the class: FulfillmentOrderNotes{}
Hooks from the method
Returns
null. Nothing (null).
Usage
$FulfillmentOrderNotes = new FulfillmentOrderNotes(); $FulfillmentOrderNotes->add_order_fulfillment_status_changed_note( $order, $old_status, $new_status ): void;
- $order(WC_Order) (required)
- The order object.
- $old_status(string) (required)
- The previous fulfillment status.
- $new_status(string) (required)
- The new fulfillment status.
FulfillmentOrderNotes::add_order_fulfillment_status_changed_note() FulfillmentOrderNotes::add order fulfillment status changed note code WC 10.7.0
public function add_order_fulfillment_status_changed_note( \WC_Order $order, string $old_status, string $new_status ): void {
$old_status_label = $this->get_order_fulfillment_status_label( $old_status );
$new_status_label = $this->get_order_fulfillment_status_label( $new_status );
$message = sprintf(
/* translators: 1: old fulfillment status label, 2: new fulfillment status label */
__( 'Order fulfillment status changed from %1$s to %2$s.', 'woocommerce' ),
$old_status_label,
$new_status_label
);
/**
* Filters the order note message when the order fulfillment status changes.
*
* Return null to cancel the note.
*
* @since 10.7.0
*
* @param string|null $message The note message.
* @param \WC_Order $order The order object.
* @param string $old_status The previous fulfillment status.
* @param string $new_status The new fulfillment status.
*/
$message = apply_filters( 'woocommerce_fulfillment_order_status_changed_order_note', $message, $order, $old_status, $new_status );
$message = $this->normalize_note_message( $message );
if ( null === $message ) {
return;
}
$order->add_order_note( $message, 0, false, array( 'note_group' => OrderNoteGroup::FULFILLMENT ) );
}