USPSShippingProvider
extends AbstractShippingProvider
in package
USPS Shipping Provider implementation.
Handles USPS tracking number detection and validation for both domestic and international shipments.
Table of Contents
- $domestic_countries : array<string|int, mixed>
- List of countries/territories where USPS offers domestic service.
- can_ship_from() : bool
- Check if the shipping provider can ship from a specific country.
- can_ship_from_to() : bool
- Checks if USPS can ship from and to the specified countries.
- can_ship_to() : bool
- Check if the shipping provider can ship to a specific country.
- get_icon() : string
- Gets the path to the provider's icon.
- get_key() : string
- Gets the unique provider key.
- get_name() : string
- Gets the display name of the provider.
- get_shipping_from_countries() : array<string|int, string>
- Gets the list of origin countries supported by USPS.
- get_shipping_to_countries() : array<string|int, string>
- Gets the list of destination countries supported by USPS.
- get_tracking_url() : string
- Generates the tracking URL for a given tracking number.
- try_parse_tracking_number() : array<string|int, mixed>|null
- Attempts to parse and validate a USPS tracking number.
Properties
$domestic_countries
List of countries/territories where USPS offers domestic service.
private
array<string|int, mixed>
$domestic_countries
= array('US', 'PR', 'GU', 'AS', 'VI', 'MP', 'FM', 'MH', 'PW')
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
bool — True if the provider can ship from the country, false otherwise.can_ship_from_to()
Checks if USPS can ship from and to the specified countries.
public
can_ship_from_to(string $shipping_from, string $shipping_to) : bool
Parameters
- $shipping_from : string
-
Origin country code.
- $shipping_to : string
-
Destination country code.
Return values
bool —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
bool — True if the provider can ship to the country, false otherwise.get_icon()
Gets the path to the provider's icon.
public
get_icon() : string
Return values
string — URL to the USPS logo image.get_key()
Gets the unique provider key.
public
get_key() : string
Return values
string — The provider key 'usps'.get_name()
Gets the display name of the provider.
public
get_name() : string
Return values
string — The provider name 'USPS'.get_shipping_from_countries()
Gets the list of origin countries supported by USPS.
public
get_shipping_from_countries() : array<string|int, string>
Return values
array<string|int, string> — Array of country codes (only 'US').get_shipping_to_countries()
Gets the list of destination countries supported by USPS.
public
get_shipping_to_countries() : array<string|int, string>
Return values
array<string|int, string> — Array of country codes including domestic and international.get_tracking_url()
Generates the tracking URL for a given tracking number.
public
get_tracking_url(string $tracking_number) : string
Parameters
- $tracking_number : string
-
The tracking number to generate URL for.
Return values
string — The complete tracking URL.try_parse_tracking_number()
Attempts to parse and validate a USPS 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 validate.
- $shipping_from : string
-
Origin country code.
- $shipping_to : string
-
Destination country code.
