EvriHermesShippingProvider
extends AbstractShippingProvider
in package
Evri (Hermes) Shipping Provider class.
Provides Evri tracking number validation, supported countries, and tracking URL generation.
Table of Contents
- CALLING_CARD_PATTERN = '/^\d{8}$/'
- Calling card pattern.
- LEGACY_PATTERNS = array('/^\d{13,15}$/')
- Legacy and fallback patterns.
- MAIN_PATTERNS = array( '/^\d{16}$/', // 16-digit numeric (official Evri/Hermes format). '/^[A-Z]{1,2}\d{14,15}$/', // H, E, HM, EV, HH, MH + 14-15 digits (legacy/retail). '/^MH\d{16}$/', // MH + 16 digits (Hermes Germany legacy)[3]. '/^(?:[A-Z]\d{2}[A-Z0-9]{13}|\d{16})$/', )
- Main Evri/Hermes tracking number patterns.
- 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 Evri tracking number.
Constants
CALLING_CARD_PATTERN
Calling card pattern.
private
mixed
CALLING_CARD_PATTERN
= '/^\d{8}$/'
LEGACY_PATTERNS
Legacy and fallback patterns.
private
mixed
LEGACY_PATTERNS
= array('/^\d{13,15}$/')
MAIN_PATTERNS
Main Evri/Hermes tracking number patterns.
private
mixed
MAIN_PATTERNS
= array(
'/^\d{16}$/',
// 16-digit numeric (official Evri/Hermes format).
'/^[A-Z]{1,2}\d{14,15}$/',
// H, E, HM, EV, HH, MH + 14-15 digits (legacy/retail).
'/^MH\d{16}$/',
// MH + 16 digits (Hermes Germany legacy)[3].
'/^(?:[A-Z]\d{2}[A-Z0-9]{13}|\d{16})$/',
)
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()
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
bool — True 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
bool — True if the provider can ship to the country, false otherwise.get_icon()
Get the icon URL for this shipping provider.
public
get_icon() : string
Return values
string — URL of the shipping provider icon.get_key()
Get the unique key for this shipping provider.
public
get_key() : string
Return values
string — Unique key.get_name()
Get the name of this shipping provider.
public
get_name() : string
Return values
string — Name of the shipping provider.get_shipping_from_countries()
Get the countries this shipping provider can ship from.
public
get_shipping_from_countries() : array<string|int, mixed>
Return values
array<string|int, mixed> — List of country codes.get_shipping_to_countries()
Get the countries this shipping provider can ship to.
public
get_shipping_to_countries() : array<string|int, mixed>
Return values
array<string|int, mixed> — List of country codes.get_tracking_url()
Get 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 the URL for.
Return values
string — The tracking URL.try_parse_tracking_number()
Try to parse an Evri 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.
