WooCommerce Code Reference

AustraliaPostShippingProvider extends AbstractShippingProvider
in package

Australia Post Shipping Provider class.

Provides Australia Post tracking number validation, supported countries, and tracking URL generation.

Table of Contents

TRACKING_PATTERNS  = array('AU' => array( // Australia. 'patterns' => array( // International UPU S10 format with validation. '/^[A-Z]{2}\d{9}AU$/', // XX#########AU. '/^[A-Z]{2}\d{7}AU$/', // Alternative international format: XX#######AU. // Domestic numeric tracking formats. '/^\d{13}$/', // 13-digit domestic tracking. '/^\d{12}$/', // 12-digit domestic tracking. '/^\d{11}$/', // 11-digit domestic tracking. // Standard alphanumeric formats. '/^[A-Z]{2}\d{8}[A-Z]{2}$/', // Standard format: XX########XX. '/^[A-Z]{1}\d{10}[A-Z]{1}$/', // Domestic format: X##########X. // Service-specific patterns. '/^[A-Z]{4}\d{8}$/', // Express Post format: XXXX########. '/^EP\d{10}$/', // Express Post specific. '/^ST\d{10}$/', // StarTrack (freight). '/^MB\d{10}$/', // MyPost Business. '/^PO\d{10}$/', // Post Office Box. // MyPost Digital formats. '/^MP\d{10,12}$/', // MyPost tracking. '/^DG\d{10,12}$/', // Digital tracking. // Parcel numeric formats. '/^7\d{15}$/', // 16-digit format starting with 7. '/^3\d{15}$/', // 16-digit format starting with 3. '/^8\d{15}$/', // 16-digit format starting with 8. // eParcel formats. '/^[A-Z]{3}\d{8,12}$/', // Three-letter prefix. '/^33\d?[A-Z]{2}\d{18,20}$/', // StarTrack eParcel. '/^AP\d{10,13}$/', // Australia Post eParcel. // Legacy and alternative formats. '/^[0-9]{10}[A-Z]{2}$/', // 10 digits + 2 letters. '/^[A-Z]{1}\d{8}[A-Z]{3}$/', ), 'confidence' => 90, ))
Australia Post tracking number patterns with enhanced service detection.
can_ship_from()  : bool
Check if the shipping provider can ship from a specific country.
can_ship_from_to()  : bool
Check if the shipping provider can ship from a specific country to another.
can_ship_to()  : bool
Check if the shipping provider can ship to a specific country.
get_icon()  : string
Get the icon URL for this shipping provider.
get_key()  : string
Get the unique key for this shipping provider.
get_name()  : string
Get the name of this shipping provider.
get_shipping_from_countries()  : array<string|int, mixed>
Get the countries this shipping provider can ship from.
get_shipping_to_countries()  : array<string|int, mixed>
Get the countries this shipping provider can ship to.
get_tracking_url()  : string
Get the tracking URL for a given tracking number.
try_parse_tracking_number()  : array<string|int, mixed>|null
Try to parse an Australia Post tracking number.
validate_country_pattern()  : bool
Validate tracking number against country-specific patterns.

Constants

TRACKING_PATTERNS

Australia Post tracking number patterns with enhanced service detection.

private array<string, array{patterns: array, confidence: int}> TRACKING_PATTERNS = array('AU' => array( // Australia. 'patterns' => array( // International UPU S10 format with validation. '/^[A-Z]{2}\d{9}AU$/', // XX#########AU. '/^[A-Z]{2}\d{7}AU$/', // Alternative international format: XX#######AU. // Domestic numeric tracking formats. '/^\d{13}$/', // 13-digit domestic tracking. '/^\d{12}$/', // 12-digit domestic tracking. '/^\d{11}$/', // 11-digit domestic tracking. // Standard alphanumeric formats. '/^[A-Z]{2}\d{8}[A-Z]{2}$/', // Standard format: XX########XX. '/^[A-Z]{1}\d{10}[A-Z]{1}$/', // Domestic format: X##########X. // Service-specific patterns. '/^[A-Z]{4}\d{8}$/', // Express Post format: XXXX########. '/^EP\d{10}$/', // Express Post specific. '/^ST\d{10}$/', // StarTrack (freight). '/^MB\d{10}$/', // MyPost Business. '/^PO\d{10}$/', // Post Office Box. // MyPost Digital formats. '/^MP\d{10,12}$/', // MyPost tracking. '/^DG\d{10,12}$/', // Digital tracking. // Parcel numeric formats. '/^7\d{15}$/', // 16-digit format starting with 7. '/^3\d{15}$/', // 16-digit format starting with 3. '/^8\d{15}$/', // 16-digit format starting with 8. // eParcel formats. '/^[A-Z]{3}\d{8,12}$/', // Three-letter prefix. '/^33\d?[A-Z]{2}\d{18,20}$/', // StarTrack eParcel. '/^AP\d{10,13}$/', // Australia Post eParcel. // Legacy and alternative formats. '/^[0-9]{10}[A-Z]{2}$/', // 10 digits + 2 letters. '/^[A-Z]{1}\d{8}[A-Z]{3}$/', ), 'confidence' => 90, ))

Methods

can_ship_from()

Check if the shipping provider can ship from a specific country.

public can_ship_from(string $country_code) : bool
Parameters
$country_code : string

The country code to check.

Return values
boolTrue if the provider can ship from the country, false otherwise.

can_ship_from_to()

Check if the shipping provider can ship from a specific country to another.

public can_ship_from_to(string $shipping_from, string $shipping_to) : bool
Parameters
$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
boolTrue if the provider can ship from the source to the destination, false otherwise.

can_ship_to()

Check if the shipping provider can ship to a specific country.

public can_ship_to(string $country_code) : bool
Parameters
$country_code : string

The country code to check.

Return values
boolTrue if the provider can ship to the country, false otherwise.

try_parse_tracking_number()

Try to parse an Australia Post tracking number.

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

The tracking number to parse.

$shipping_from : string

The country code of the shipping origin.

$shipping_to : string

The country code of the shipping destination.

Return values
array<string|int, mixed>|nullAn array with 'url' and 'ambiguity_score' if valid, null otherwise.

validate_country_pattern()

Validate tracking number against country-specific patterns.

private validate_country_pattern(string $tracking_number, string $country_code) : bool
Parameters
$tracking_number : string

The tracking number to validate.

$country_code : string

The country code for the shipment.

Return values
boolTrue if valid, false otherwise.