FulfillmentUtils
in package
Class FulfillmentUtils
Utility class for handling order fulfillments.
Table of Contents
- calculate_order_fulfillment_status() : string
- Get the fulfillment status of the entity. This runs like a computed property, where it checks the fulfillment status of each fulfillment attached to the order, and computes the overall fulfillment status of the order.
- check_s10_upu_format() : bool
- Calculate the S10 check digit for UPU tracking numbers.
- get_all_items_of_fulfillments() : array<string|int, mixed>
- Get all items from the fulfillments.
- get_fulfillment_items() : array<string|int, mixed>
- Get order items for a fulfillment.
- get_fulfillment_statuses() : array<string|int, mixed>
- Get the fulfillment statuses.
- get_order_fulfillment_status() : string
- Get the fulfillment status of an order.
- get_order_fulfillment_status_meta_query() : array<string|int, mixed>
- Get the meta query for the order fulfillment status.
- get_order_fulfillment_status_text() : string
- Get the fulfillment status text for an order.
- get_order_fulfillment_statuses() : array<string|int, mixed>
- Get the order fulfillment statuses.
- get_pending_items() : array<string|int, mixed>
- Get pending items for an order.
- get_refunded_items() : array<string|int, mixed>
- Get refunded items for an order.
- get_shipping_providers() : array<string|int, AbstractShippingProvider>
- Get the shipping providers.
- get_tracking_info_html() : string
- Get the HTML for the fulfillment tracking number.
- has_pending_items() : bool
- Check if an order has pending items.
- is_valid_fulfillment_status() : bool
- Check if the given fulfillment status is valid.
- is_valid_order_fulfillment_status() : bool
- Check if the given fulfillment status is valid.
- resolve_provider_name() : string
- Resolve the provider name for a fulfillment.
- validate_fedex_check_digit() : bool
- Validate FedEx check digit for 12/14-digit tracking numbers.
- validate_mod10_check_digit() : bool
- Validate Mod 10 check digit for numeric tracking numbers.
- validate_mod11_check_digit() : bool
- Validate Mod 11 check digit for tracking numbers (used by DHL).
- validate_mod7_check_digit() : bool
- Validate Mod 7 check digit for numeric tracking numbers.
- validate_ups_1z_check_digit() : bool
- Validate UPS 1Z tracking number using Mod 10 check digit.
- get_default_fulfillment_statuses() : array<string|int, mixed>
- Get the default fulfillment statuses.
- get_default_order_fulfillment_statuses() : array<string|int, mixed>
- Get the default order fulfillment statuses.
Methods
calculate_order_fulfillment_status()
Get the fulfillment status of the entity. This runs like a computed property, where it checks the fulfillment status of each fulfillment attached to the order, and computes the overall fulfillment status of the order.
public
static calculate_order_fulfillment_status(WC_Order $order[, array<string|int, mixed> $fulfillments = array() ]) : string
Parameters
- $order : WC_Order
-
The order object.
- $fulfillments : array<string|int, mixed> = array()
-
An array of fulfillments to check.
Return values
string — The fulfillment status.check_s10_upu_format()
Calculate the S10 check digit for UPU tracking numbers.
public
static check_s10_upu_format(string $tracking_number) : bool
Parameters
- $tracking_number : string
-
The tracking number without the check digit.
Return values
bool — True if the check digit is valid, false otherwise.get_all_items_of_fulfillments()
Get all items from the fulfillments.
public
static get_all_items_of_fulfillments(array<string|int, mixed> $fulfillments) : array<string|int, mixed>
Parameters
- $fulfillments : array<string|int, mixed>
-
An array of fulfillments.
Return values
array<string|int, mixed> — An associative array of item IDs and their quantities.get_fulfillment_items()
Get order items for a fulfillment.
public
static get_fulfillment_items(WC_Order $order, Fulfillment $fulfillment) : array<string|int, mixed>
Parameters
- $order : WC_Order
-
The order object.
- $fulfillment : Fulfillment
-
The fulfillment object.
Return values
array<string|int, mixed> — An array of order items.get_fulfillment_statuses()
Get the fulfillment statuses.
public
static get_fulfillment_statuses() : array<string|int, mixed>
This method provides the fulfillment statuses that can be used
in the WooCommerce Fulfillments system. It can be filtered using the
woocommerce_fulfillment_fulfillment_statuses filter.
Return values
array<string|int, mixed> — An associative array of fulfillment statuses.get_order_fulfillment_status()
Get the fulfillment status of an order.
public
static get_order_fulfillment_status(WC_Order $order) : string
Parameters
- $order : WC_Order
-
The order object.
Return values
string — The fulfillment status.get_order_fulfillment_status_meta_query()
Get the meta query for the order fulfillment status.
public
static get_order_fulfillment_status_meta_query(array<string|int, mixed>|string $statuses) : array<string|int, mixed>
Parameters
- $statuses : array<string|int, mixed>|string
-
The fulfillment statuses, or single status.
Return values
array<string|int, mixed> — The meta query.get_order_fulfillment_status_text()
Get the fulfillment status text for an order.
public
static get_order_fulfillment_status_text(WC_Order $order) : string
Parameters
- $order : WC_Order
-
The order object.
Return values
string — The fulfillment status text.get_order_fulfillment_statuses()
Get the order fulfillment statuses.
public
static get_order_fulfillment_statuses() : array<string|int, mixed>
This method provides the order fulfillment statuses that can be used
in the WooCommerce Fulfillments system. It can be filtered using the
woocommerce_fulfillment_order_fulfillment_statuses filter.
Return values
array<string|int, mixed> — An associative array of order fulfillment statuses.get_pending_items()
Get pending items for an order.
public
static get_pending_items(WC_Order $order, array<string|int, mixed> $fulfillments[, bool $without_refunds = true ]) : array<string|int, mixed>
Parameters
- $order : WC_Order
-
The order object.
- $fulfillments : array<string|int, mixed>
-
An array of fulfillments to check.
- $without_refunds : bool = true
-
Whether to exclude refunded items from the pending items.
Return values
array<string|int, mixed> — An array of pending items.get_refunded_items()
Get refunded items for an order.
public
static get_refunded_items(WC_Order $order) : array<string|int, mixed>
Parameters
- $order : WC_Order
-
The order object.
Return values
array<string|int, mixed> — An array of refunded items with their IDs and quantities.get_shipping_providers()
Get the shipping providers.
public
static get_shipping_providers() : array<string|int, AbstractShippingProvider>
This method retrieves the shipping providers registered in the WooCommerce Fulfillments system.
It can be filtered using the woocommerce_fulfillment_shipping_providers filter.
Any class name strings in the filter result are resolved into AbstractShippingProvider instances via the DI container. Invalid entries are silently skipped.
Return values
array<string|int, AbstractShippingProvider> — An associative array of shipping provider instances keyed by provider key.get_tracking_info_html()
Get the HTML for the fulfillment tracking number.
public
static get_tracking_info_html(Fulfillment $fulfillment) : string
Parameters
- $fulfillment : Fulfillment
-
The fulfillment object.
Return values
string — The HTML for the tracking number.has_pending_items()
Check if an order has pending items.
public
static has_pending_items(WC_Order $order, array<string|int, mixed> $fulfillments) : bool
Parameters
- $order : WC_Order
-
The order object.
- $fulfillments : array<string|int, mixed>
-
An array of fulfillments to check.
Return values
bool — True if there are pending items, false otherwise.is_valid_fulfillment_status()
Check if the given fulfillment status is valid.
public
static is_valid_fulfillment_status(string|null $status) : bool
Parameters
- $status : string|null
-
The fulfillment status to check.
Return values
bool — True if the status is valid, false otherwise.is_valid_order_fulfillment_status()
Check if the given fulfillment status is valid.
public
static is_valid_order_fulfillment_status(string|null $status) : bool
Parameters
- $status : string|null
-
The fulfillment status to check.
Return values
bool — True if the status is valid, false otherwise.resolve_provider_name()
Resolve the provider name for a fulfillment.
public
static resolve_provider_name(Fulfillment $fulfillment) : string
For custom providers ("other"), the display name from _provider_name meta is used. For known providers, the slug from _shipment_provider meta is preferred, but the display name is used as a fallback when the slug is empty (e.g., when auto-lookup identified the provider but did not set the slug).
Parameters
- $fulfillment : Fulfillment
-
The fulfillment object.
Tags
Return values
string — The resolved provider name.validate_fedex_check_digit()
Validate FedEx check digit for 12/14-digit tracking numbers.
public
static validate_fedex_check_digit(string $tracking_number) : bool
Parameters
- $tracking_number : string
-
The FedEx tracking number.
Return values
bool — True if valid, false otherwise.validate_mod10_check_digit()
Validate Mod 10 check digit for numeric tracking numbers.
public
static validate_mod10_check_digit(string $tracking_number) : bool
Parameters
- $tracking_number : string
-
The numeric tracking number.
Return values
bool — True if valid, false otherwise.validate_mod11_check_digit()
Validate Mod 11 check digit for tracking numbers (used by DHL).
public
static validate_mod11_check_digit(string $tracking_number) : bool
Parameters
- $tracking_number : string
-
The tracking number.
Return values
bool — True if valid, false otherwise.validate_mod7_check_digit()
Validate Mod 7 check digit for numeric tracking numbers.
public
static validate_mod7_check_digit(string $tracking_number) : bool
Parameters
- $tracking_number : string
-
The numeric tracking number.
Return values
bool — True if valid, false otherwise.validate_ups_1z_check_digit()
Validate UPS 1Z tracking number using Mod 10 check digit.
public
static validate_ups_1z_check_digit(string $tracking_number) : bool
Parameters
- $tracking_number : string
-
The UPS 1Z tracking number.
Return values
bool — True if valid, false otherwise.get_default_fulfillment_statuses()
Get the default fulfillment statuses.
protected
static get_default_fulfillment_statuses() : array<string|int, mixed>
This method provides the default fulfillment statuses that can be used
in the WooCommerce Fulfillments system. It can be filtered using the
woocommerce_fulfillment_fulfillment_statuses filter.
Return values
array<string|int, mixed> — An associative array of default fulfillment statuses.get_default_order_fulfillment_statuses()
Get the default order fulfillment statuses.
protected
static get_default_order_fulfillment_statuses() : array<string|int, mixed>
This method provides the default order fulfillment statuses that can be used
in the WooCommerce Fulfillments system. It can be filtered using the
woocommerce_fulfillment_order_fulfillment_statuses filter.
