WooCommerce Code Reference

FulfillmentsManager

FulfillmentsManager class.

This class is responsible for adding hooks related to fulfillments in WooCommerce.

Tags
since
10.1.0

Table of Contents

$fulfillment_order_notes  : FulfillmentOrderNotes|null
The fulfillment order notes instance.
delete_order_fulfillments()  : void
Delete all fulfillment records for an order that is being permanently deleted.
get_custom_shipping_providers()  : array<string|int, mixed>
Load custom shipping providers from the wc_fulfillment_shipping_provider taxonomy.
get_initial_shipping_providers()  : array<string|int, mixed>
Get initial shipping providers.
register()  : mixed
This method registers the hooks related to fulfillments.
translate_fulfillment_meta_key()  : string
Translate fulfillment meta keys.
try_parse_tracking_number()  : array<string|int, mixed>
Try to parse the tracking number with additional parameters.
update_fulfillment_status_after_refund_deleted()  : void
Update fulfillment status after a refund is deleted.
update_fulfillments_after_refund()  : void
Update fulfillments after a refund is created.
update_order_fulfillment_status_on_fulfillment_update()  : mixed
Update order fulfillment status after a fulfillment is created, updated, or deleted.
get_best_parsing_result()  : array<string|int, mixed>
Get the best parsing result from multiple results.
init_email_template_tracking_hooks()  : void
Initialize hooks to track when fulfillment email templates are customized.
init_fulfillment_status_hooks()  : mixed
Hook fulfillment status events.
init_order_deletion_hooks()  : void
Initialize order deletion hooks.
init_refund_hooks()  : mixed
Initialize refund-related hooks.
update_fulfillment_status()  : mixed
Update the fulfillment status for the order.

Properties

Methods

delete_order_fulfillments()

Delete all fulfillment records for an order that is being permanently deleted.

public delete_order_fulfillments(int $order_id) : void
Parameters
$order_id : int

The ID of the order being deleted.

Tags
since
10.7.0
Return values
void

get_custom_shipping_providers()

Load custom shipping providers from the wc_fulfillment_shipping_provider taxonomy.

public get_custom_shipping_providers(array<string|int, mixed> $shipping_providers) : array<string|int, mixed>
Parameters
$shipping_providers : array<string|int, mixed>

The current list of shipping providers.

Tags
since
10.7.0
Return values
array<string|int, mixed>The modified list of shipping providers with custom providers appended.

get_initial_shipping_providers()

Get initial shipping providers.

public get_initial_shipping_providers(array<string|int, mixed> $shipping_providers) : array<string|int, mixed>

This method provides the initial shipping providers that feeds the woocommerce_fulfillment_shipping_providers filter, which is used to populate the list of available shipping providers on the fulfillment UI.

Parameters
$shipping_providers : array<string|int, mixed>

The current list of shipping providers.

Return values
array<string|int, mixed>The modified list of shipping providers.

translate_fulfillment_meta_key()

Translate fulfillment meta keys.

public translate_fulfillment_meta_key(string $meta_key) : string
Parameters
$meta_key : string

The meta key to translate.

Return values
stringTranslated meta key.

try_parse_tracking_number()

Try to parse the tracking number with additional parameters.

public try_parse_tracking_number(string $tracking_number, string $shipping_from, string $shipping_to) : array<string|int, mixed>
Parameters
$tracking_number : string

The tracking number.

$shipping_from : string

The country code from which the shipment is sent.

$shipping_to : string

The country code to which the shipment is sent.

Return values
array<string|int, mixed>An array containing the provider as key, and the parsing results.

update_fulfillment_status_after_refund_deleted()

Update fulfillment status after a refund is deleted.

public update_fulfillment_status_after_refund_deleted(int $refund_id) : void

This method updates the fulfillment status after a refund is deleted to ensure that the fulfillment status and items are correctly adjusted based on the refund deletion.

Parameters
$refund_id : int

The ID of the refund being deleted.

Return values
void

update_fulfillments_after_refund()

Update fulfillments after a refund is created.

public update_fulfillments_after_refund(int $refund_id) : void
Parameters
$refund_id : int

The ID of the refund created.

Return values
void

get_best_parsing_result()

Get the best parsing result from multiple results.

private get_best_parsing_result(array<string|int, mixed> $results, string $tracking_number) : array<string|int, mixed>

This method finds the provider with the highest ambiguity score from the results.

Parameters
$results : array<string|int, mixed>

The results from multiple providers.

$tracking_number : string

The tracking number being parsed.

Return values
array<string|int, mixed>The best parsing result.

init_email_template_tracking_hooks()

Initialize hooks to track when fulfillment email templates are customized.

private init_email_template_tracking_hooks() : void

Hooks into the WooCommerce email settings save action for each fulfillment email type so we can track when merchants customize these templates.

Return values
void

init_fulfillment_status_hooks()

Hook fulfillment status events.

private init_fulfillment_status_hooks() : mixed

This method hooks into the fulfillment status events to update the order fulfillment status when a fulfillment is created, updated, or deleted.

Return values
mixed

init_order_deletion_hooks()

Initialize order deletion hooks.

private init_order_deletion_hooks() : void

Registers hooks to clean up fulfillment records when an order is permanently deleted.

Return values
void

init_refund_hooks()

Initialize refund-related hooks.

private init_refund_hooks() : mixed

This method initializes the hooks related to refunds, such as updating fulfillments after a refund is created

Return values
mixed

update_fulfillment_status()

Update the fulfillment status for the order.

private update_fulfillment_status(WC_Order $order[, array<string|int, mixed> $fulfillments = array() ]) : mixed
Parameters
$order : WC_Order

The order object.

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

The fulfillments data store.

This method updates the fulfillment status for the order based on the fulfillments data store.

Return values
mixed