DPDShippingProvider
extends AbstractShippingProvider
in package
DPD Shipping Provider class.
Provides DPD tracking number validation, supported countries, and tracking URL generation.
Table of Contents
- INTERNATIONAL_PATTERN = '/^\d{28}$/'
- International shipment pattern (28 digits)
- S10_PATTERN = '/^[A-Z]{2}\d{9}[A-Z]{2}$/'
- S10/UPU international pattern.
- TRACKING_PATTERNS = array('DE' => array( // Germany. 'patterns' => array( '/^\d{14}$/', '/^\d{12}$/', '/^02\d{12}$/', // DPD Classic. '/^05\d{12}$/', // DPD Express. '/^09\d{12}$/', // DPD Predict. '/^[A-Z]{2}\d{9}[A-Z]{2}$/', // S10/UPU international. '/^\d{24}$/', ), 'confidence' => 80, 'services' => array('classic' => 80, 'express' => 85, 'predict' => 85, 's10' => 90), ), 'GB' => array( // United Kingdom. 'patterns' => array( '/^\d{14}$/', '/^[A-Z]{2}\d{9}GB$/', '/^03\d{12}$/', // DPD Next Day. '/^06\d{12}$/', // DPD Express. '/^1[56]\d{12}$/', // Predict/Return. '/^[A-Z]{2}\d{9}[A-Z]{2}$/', // S10/UPU international. '/^\d{24}$/', ), 'confidence' => 90, 'services' => array('next_day' => 88, 'express' => 88, 's10' => 90), ), 'FR' => array( // France. 'patterns' => array( '/^\d{14}$/', '/^\d{12}$/', '/^02\d{12}$/', // DPD Relais. '/^04\d{12}$/', // DPD Predict. '/^[A-Z]{2}\d{9}[A-Z]{2}$/', // S10/UPU international. '/^\d{24}$/', ), 'confidence' => 78, 'services' => array('relais' => 82, 'predict' => 82, 's10' => 90), ), 'NL' => array( // Netherlands. 'patterns' => array( '/^\d{14}$/', '/^\d{12}$/', '/^03\d{12}$/', // DPD Classic. '/^07\d{12}$/', // DPD Express. '/^[A-Z]{2}\d{9}[A-Z]{2}$/', // S10/UPU international. '/^\d{24}$/', ), 'confidence' => 78, 'services' => array('classic' => 82, 'express' => 85, 's10' => 90), ), 'BE' => array( // Belgium. 'patterns' => array( '/^\d{14}$/', '/^\d{12}$/', '/^03\d{12}$/', // DPD Classic. '/^08\d{12}$/', // DPD Express. '/^[A-Z]{2}\d{9}[A-Z]{2}$/', // S10/UPU international. '/^\d{24}$/', ), 'confidence' => 78, 'services' => array('classic' => 82, 'express' => 85, 's10' => 90), ), 'PL' => array( // Poland. 'patterns' => array( '/^\d{14}$/', '/^[A-Z]{2}\d{10}$/', '/^[A-Z]{2}\d{9}[A-Z]{2}$/', // S10/UPU international. '/^\d{24}$/', ), 'confidence' => 90, ), 'IE' => array( // Ireland. 'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{9}IE$/'), 'confidence' => 85, ), 'AT' => array( // Austria. 'patterns' => array('/^\d{14}$/', '/^\d{12}$/'), 'confidence' => 75, ), 'CH' => array( // Switzerland. 'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{9}CH$/'), 'confidence' => 85, ), 'ES' => array( // Spain. 'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'), 'confidence' => 85, ), 'IT' => array( // Italy. 'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'), 'confidence' => 85, ), 'LU' => array( // Luxembourg. 'patterns' => array('/^\d{14}$/', '/^\d{12}$/'), 'confidence' => 75, ), 'CZ' => array( // Czech Republic. 'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'), 'confidence' => 90, ), 'SK' => array( // Slovakia. 'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'), 'confidence' => 90, ), 'HU' => array( // Hungary. 'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'), 'confidence' => 90, ), 'SI' => array( // Slovenia. 'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'), 'confidence' => 80, ), 'HR' => array( // Croatia. 'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'), 'confidence' => 80, ), 'RO' => array( // Romania. 'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'), 'confidence' => 75, ), 'BG' => array( // Bulgaria. 'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'), 'confidence' => 70, ), 'LT' => array( // Lithuania. 'patterns' => array('/^\d{14}$/', '/^\d{12}$/'), 'confidence' => 70, ), 'LV' => array( // Latvia. 'patterns' => array('/^\d{14}$/', '/^\d{12}$/'), 'confidence' => 70, ), 'EE' => array( // Estonia. 'patterns' => array('/^\d{14}$/', '/^\d{12}$/'), 'confidence' => 70, ), 'FI' => array( // Finland. 'patterns' => array('/^\d{14}$/', '/^\d{12}$/'), 'confidence' => 65, ), 'DK' => array( // Denmark. 'patterns' => array('/^\d{14}$/', '/^\d{12}$/'), 'confidence' => 65, ), 'SE' => array( // Sweden. 'patterns' => array('/^\d{14}$/', '/^\d{12}$/'), 'confidence' => 65, ), 'NO' => array( // Norway. 'patterns' => array('/^\d{14}$/', '/^\d{12}$/'), 'confidence' => 60, ), 'GR' => array( // Greece. 'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'), 'confidence' => 85, ), 'PT' => array( // Portugal. 'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'), 'confidence' => 85, ))
- DPD tracking number patterns by country with service differentiation.
- 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 description of this shipping provider.
- 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 a DPD tracking number.
- validate_country_pattern() : array<string|int, mixed>|bool
- Validate tracking number against country-specific patterns and determine service type.
Constants
INTERNATIONAL_PATTERN
International shipment pattern (28 digits)
private
mixed
INTERNATIONAL_PATTERN
= '/^\d{28}$/'
S10_PATTERN
S10/UPU international pattern.
private
mixed
S10_PATTERN
= '/^[A-Z]{2}\d{9}[A-Z]{2}$/'
TRACKING_PATTERNS
DPD tracking number patterns by country with service differentiation.
private
array<string, array{patterns: array, confidence: int, services?: array}>
TRACKING_PATTERNS
= array('DE' => array(
// Germany.
'patterns' => array(
'/^\d{14}$/',
'/^\d{12}$/',
'/^02\d{12}$/',
// DPD Classic.
'/^05\d{12}$/',
// DPD Express.
'/^09\d{12}$/',
// DPD Predict.
'/^[A-Z]{2}\d{9}[A-Z]{2}$/',
// S10/UPU international.
'/^\d{24}$/',
),
'confidence' => 80,
'services' => array('classic' => 80, 'express' => 85, 'predict' => 85, 's10' => 90),
), 'GB' => array(
// United Kingdom.
'patterns' => array(
'/^\d{14}$/',
'/^[A-Z]{2}\d{9}GB$/',
'/^03\d{12}$/',
// DPD Next Day.
'/^06\d{12}$/',
// DPD Express.
'/^1[56]\d{12}$/',
// Predict/Return.
'/^[A-Z]{2}\d{9}[A-Z]{2}$/',
// S10/UPU international.
'/^\d{24}$/',
),
'confidence' => 90,
'services' => array('next_day' => 88, 'express' => 88, 's10' => 90),
), 'FR' => array(
// France.
'patterns' => array(
'/^\d{14}$/',
'/^\d{12}$/',
'/^02\d{12}$/',
// DPD Relais.
'/^04\d{12}$/',
// DPD Predict.
'/^[A-Z]{2}\d{9}[A-Z]{2}$/',
// S10/UPU international.
'/^\d{24}$/',
),
'confidence' => 78,
'services' => array('relais' => 82, 'predict' => 82, 's10' => 90),
), 'NL' => array(
// Netherlands.
'patterns' => array(
'/^\d{14}$/',
'/^\d{12}$/',
'/^03\d{12}$/',
// DPD Classic.
'/^07\d{12}$/',
// DPD Express.
'/^[A-Z]{2}\d{9}[A-Z]{2}$/',
// S10/UPU international.
'/^\d{24}$/',
),
'confidence' => 78,
'services' => array('classic' => 82, 'express' => 85, 's10' => 90),
), 'BE' => array(
// Belgium.
'patterns' => array(
'/^\d{14}$/',
'/^\d{12}$/',
'/^03\d{12}$/',
// DPD Classic.
'/^08\d{12}$/',
// DPD Express.
'/^[A-Z]{2}\d{9}[A-Z]{2}$/',
// S10/UPU international.
'/^\d{24}$/',
),
'confidence' => 78,
'services' => array('classic' => 82, 'express' => 85, 's10' => 90),
), 'PL' => array(
// Poland.
'patterns' => array(
'/^\d{14}$/',
'/^[A-Z]{2}\d{10}$/',
'/^[A-Z]{2}\d{9}[A-Z]{2}$/',
// S10/UPU international.
'/^\d{24}$/',
),
'confidence' => 90,
), 'IE' => array(
// Ireland.
'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{9}IE$/'),
'confidence' => 85,
), 'AT' => array(
// Austria.
'patterns' => array('/^\d{14}$/', '/^\d{12}$/'),
'confidence' => 75,
), 'CH' => array(
// Switzerland.
'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{9}CH$/'),
'confidence' => 85,
), 'ES' => array(
// Spain.
'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'),
'confidence' => 85,
), 'IT' => array(
// Italy.
'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'),
'confidence' => 85,
), 'LU' => array(
// Luxembourg.
'patterns' => array('/^\d{14}$/', '/^\d{12}$/'),
'confidence' => 75,
), 'CZ' => array(
// Czech Republic.
'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'),
'confidence' => 90,
), 'SK' => array(
// Slovakia.
'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'),
'confidence' => 90,
), 'HU' => array(
// Hungary.
'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'),
'confidence' => 90,
), 'SI' => array(
// Slovenia.
'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'),
'confidence' => 80,
), 'HR' => array(
// Croatia.
'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'),
'confidence' => 80,
), 'RO' => array(
// Romania.
'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'),
'confidence' => 75,
), 'BG' => array(
// Bulgaria.
'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'),
'confidence' => 70,
), 'LT' => array(
// Lithuania.
'patterns' => array('/^\d{14}$/', '/^\d{12}$/'),
'confidence' => 70,
), 'LV' => array(
// Latvia.
'patterns' => array('/^\d{14}$/', '/^\d{12}$/'),
'confidence' => 70,
), 'EE' => array(
// Estonia.
'patterns' => array('/^\d{14}$/', '/^\d{12}$/'),
'confidence' => 70,
), 'FI' => array(
// Finland.
'patterns' => array('/^\d{14}$/', '/^\d{12}$/'),
'confidence' => 65,
), 'DK' => array(
// Denmark.
'patterns' => array('/^\d{14}$/', '/^\d{12}$/'),
'confidence' => 65,
), 'SE' => array(
// Sweden.
'patterns' => array('/^\d{14}$/', '/^\d{12}$/'),
'confidence' => 65,
), 'NO' => array(
// Norway.
'patterns' => array('/^\d{14}$/', '/^\d{12}$/'),
'confidence' => 60,
), 'GR' => array(
// Greece.
'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'),
'confidence' => 85,
), 'PT' => array(
// Portugal.
'patterns' => array('/^\d{14}$/', '/^[A-Z]{2}\d{10}$/'),
'confidence' => 85,
))
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 description of this shipping provider.
public
get_shipping_from_countries() : array<string|int, mixed>
Return values
array<string|int, mixed> — Description of the shipping provider.get_shipping_to_countries()
Get the countries this shipping provider can ship to.
public
get_shipping_to_countries() : array<string|int, mixed>
DPD typically ships within Europe, so we return the same countries as shipping from.
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 a DPD 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>|null — An array with 'url' and 'ambiguity_score' if valid, null otherwise.validate_country_pattern()
Validate tracking number against country-specific patterns and determine service type.
private
validate_country_pattern(string $tracking_number, string $country_code) : array<string|int, mixed>|bool
Parameters
- $tracking_number : string
-
The tracking number to validate.
- $country_code : string
-
The country code for the shipment.
