CustomShippingProvider
extends AbstractShippingProvider
in package
Custom shipping provider loaded from the wc_fulfillment_shipping_provider taxonomy.
Unlike built-in providers, custom providers do not support automatic tracking number parsing; they rely on user-supplied tracking URL templates.
Tags
Table of Contents
- $icon : string
- The provider icon URL.
- $key : string
- The provider key (taxonomy term slug).
- $name : string
- The provider display name.
- $tracking_url_template : string
- The tracking URL template containing __PLACEHOLDER__ for the tracking number.
- __construct() : mixed
- Constructor.
- 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 of the shipping provider.
- get_key() : string
- Get the key of the shipping provider.
- get_name() : string
- Get the name of the shipping provider.
- get_shipping_from_countries() : array<string|int, mixed>
- Get the countries from which the shipping provider can ship.
- get_shipping_to_countries() : array<string|int, mixed>
- Get the countries to which the shipping provider can ship.
- get_tracking_url() : string
- Get the tracking URL for a given tracking number.
- try_parse_tracking_number() : array<string|int, mixed>|null
- Custom providers do not support automatic tracking number parsing.
Properties
$icon
The provider icon URL.
private
string
$icon
$key
The provider key (taxonomy term slug).
private
string
$key
$name
The provider display name.
private
string
$name
$tracking_url_template
The tracking URL template containing __PLACEHOLDER__ for the tracking number.
private
string
$tracking_url_template
Methods
__construct()
Constructor.
public
__construct(string $key, string $name, string $icon, string $tracking_url_template) : mixed
Parameters
- $key : string
-
The provider key (term slug).
- $name : string
-
The provider display name.
- $icon : string
-
The provider icon URL.
- $tracking_url_template : string
-
The tracking URL template.
Return values
mixed —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 of the shipping provider.
public
get_icon() : string
Return values
string —get_key()
Get the key of the shipping provider.
public
get_key() : string
Return values
string —get_name()
Get the name of the shipping provider.
public
get_name() : string
Return values
string —get_shipping_from_countries()
Get the countries from which the shipping provider can ship.
public
get_shipping_from_countries() : array<string|int, mixed>
Return values
array<string|int, mixed> — An array of country codes.get_shipping_to_countries()
Get the countries to which the shipping provider can ship.
public
get_shipping_to_countries() : array<string|int, mixed>
Return values
array<string|int, mixed> — An array of country codes.get_tracking_url()
Get the tracking URL for a given tracking number.
public
get_tracking_url(string $tracking_number) : string
Replaces PLACEHOLDER in the template with the actual tracking number.
Parameters
- $tracking_number : string
-
The tracking number.
Return values
string — The tracking URL with the placeholder replaced.try_parse_tracking_number()
Custom providers do not support automatic tracking number parsing.
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.
- $shipping_from : string
-
The country code from which the shipment is sent.
- $shipping_to : string
-
The country code to which the shipment is sent.
