shipcloud for WooCommerce

WC_Shipping_Shipcloud_API_Adapter
in package

Table of Contents

$api  : ApiClient
ApiClient instance
$api_key  : string
The shipcloud API key
$instance  : object
The Single instance of the class
$services  : array<string|int, mixed>
Services list
create_address()  : array<string|int, mixed>
This method is to create an address. It forces a validation against required fields before sending the request to API.
create_label()  : array<string|int, mixed>|WP_Error
Creating a shipping label
create_pickup_request()  : array<string|int, mixed>|WP_Error
There are two ways you can request shipments to be picked up by a specific carrier. By simply stating that all shipments that haven't been picked up already should be picked up or by specifying which shipments should by picked up.
create_shipment()  : array<string|int, mixed>|WP_Error
This method is to create a shipment.
create_tracker()  : array<string|int, mixed>|bool
If you want to create a tracker, this is the way to go.
delete_shipment()  : array<string|int, mixed>|bool|WP_Error
This method is to delete an existing shipment.
get_address()  : array<string|int, mixed>|WP_Error
If you want to obtain a certain address, this is the way to go.
get_address_by_pakadoo_id()  : array<string|int, mixed>|WP_Error
If you want to request a pakadoo point address, this is the way to go.
get_addresses()  : array<string|int, mixed>|WP_Error
If you want to obtain a list of addresses, this is the way to go.
get_carrier_list()  : array<string|int, mixed>
Get a list of carriers available for your account.
get_carriers()  : array<string|int, mixed>|false
Get all carriers available for your shipcloud account.
get_current_shipment_status()  : array<string|int, mixed>|WP_Error
Getting the get current status of a certain shipment.
get_default_returns_address()  : array<string|int, mixed>|WP_Error
This is the default address that will be used for returns shipments when no address was specified using the 'to' attribute.
get_default_shipping_address()  : array<string|int, mixed>
This is the default address that will be used for shipments when no address was specified using the 'from' attribute.
get_instance()  : object
Main Instance
get_invoice_address()  : array<string|int, mixed>|WP_Error
This is the address that a user has specified as being their invoice address.
get_pickup_request()  : array<string|int, mixed>|bool
Getting information about a certain pickup request.
get_pickup_requests()  : array<string|int, mixed>
Getting a list of pickup requests.
get_price()  : float|WP_Error
Getting the price for a shipment
get_shipment()  : array<string|int, mixed>|WP_Error
If you want to obtain a certain shipment, this is the way to go.
get_shipments()  : array<string|int, mixed>|WP_Error
If you want to obtain a list of shipments, this is the way to go.
get_tracker()  : array<string|int, mixed>|bool
Getting information about a certain tracker.
get_trackers()  : array<string|int, mixed>
Getting a list of trackers.
get_webhook_id()  : mixed
update_shipment()  : array<string|int, mixed>|WP_Error
This method is to update an existing shipment.
__construct()  : void
Constructor.
add_admin_notice()  : void
Output an admin notice.
convert_data_array_to_address_api_object()  : Address
Converts address data array to Address.
convert_data_array_to_pickup_api_object()  : Pickup
Converts pickup data array to Pickup.
convert_data_array_to_shipment_api_object()  : Shipment
Converts shipment data array to Shipment.
convert_data_array_to_tracker_api_object()  : Tracker
Converts tracker data array to Tracker.
create_shipment_quote()  : float|WP_Error
With this call you can find out how much we will charge you for a specific shipment.
create_webhook()  : string|bool
If you want to create a webhook, this is the way to go.
get_api()  : WP_Error|ApiClient
Getting shipcloud API.
get_latest_tracking_status()  : array<string|int, mixed>|bool
Extracting latest tracking information of a certain shipment.
get_service_display_name()  : string
Getting service display name by service id.
handle_exception()  : WP_Error
Handles Exception and converts it to WP_Error.
init()  : void
Initialization.
log()  : void
Output a debug message.

Properties

Methods

create_address()

This method is to create an address. It forces a validation against required fields before sending the request to API.

public create_address([array<string|int, mixed> $data = [] ]) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed> = []

The address to be created.

Return values
array<string|int, mixed>

The created address including ID.

create_label()

Creating a shipping label

public create_label([array<string|int, mixed> $shipment = [] ]) : array<string|int, mixed>|WP_Error
Parameters
$shipment : array<string|int, mixed> = []
Return values
array<string|int, mixed>|WP_Error

create_pickup_request()

There are two ways you can request shipments to be picked up by a specific carrier. By simply stating that all shipments that haven't been picked up already should be picked up or by specifying which shipments should by picked up.

public create_pickup_request([array<string|int, mixed> $data = [] ]) : array<string|int, mixed>|WP_Error

Notice: If you don't supply a pickup_address in your request, we're using the default from address that's being defined in the shipcloud profile for requesting a pickup by the carrier. Please keep in mind there are carrier specific field lengths you have to take into account.

Parameters
$data : array<string|int, mixed> = []

The pickup data.

Return values
array<string|int, mixed>|WP_Error

An array with pickup information if succeeded, false otherwise.

create_shipment()

This method is to create a shipment.

public create_shipment([mixed $data = [] ]) : array<string|int, mixed>|WP_Error
Response:
{
  "id": "3a186c51d4281acbecf5ed38805b1db92a9d668b",
  "carrier_tracking_no": "84168117830018",
  "tracking_url": "https://track.shipcloud.io/3a186c51d4",
  "label_url": "https://shipping-labels.shipcloud.io/shipments/01370b4d/199f803bf8/label/shipping_label_199f803bf8.pdf",
  "price": 3.4
}
Parameters
$data : mixed = []
Return values
array<string|int, mixed>|WP_Error

The shipment labeling, tracking and pricing information.

create_tracker()

If you want to create a tracker, this is the way to go.

public create_tracker([array<string|int, mixed> $data = [] ]) : array<string|int, mixed>|bool
Parameters
$data : array<string|int, mixed> = []

The tracker data.

Return values
array<string|int, mixed>|bool

An array with tracker information if succeeded, false otherwise.

delete_shipment()

This method is to delete an existing shipment.

public delete_shipment([ $id = '' ]) : array<string|int, mixed>|bool|WP_Error
NOTE:
Prepared shipments (create_shipping_label is false) can be deleted
at any time, because no transaction with the carrier has happened
until this point and no actual shipping label has been created. In
case you've created a shipping label you can delete it before the
cutoff time of the carrier. Cutoff times differ from carrier to
carrier and are some time between 5pm and 8pm.
Parameters
$id : = ''

The id attribute that was returned when creating the shipment.

Return values
array<string|int, mixed>|bool|WP_Error

An empty array if succeeded, false otherwise.

get_address()

If you want to obtain a certain address, this is the way to go.

public get_address([string $id = '' ]) : array<string|int, mixed>|WP_Error
Parameters
$id : string = ''

The id attribute that was returned when creating the address.

Return values
array<string|int, mixed>|WP_Error

The address if existing.

get_address_by_pakadoo_id()

If you want to request a pakadoo point address, this is the way to go.

public get_address_by_pakadoo_id([string $pakadoo_id = '' ]) : array<string|int, mixed>|WP_Error
Parameters
$pakadoo_id : string = ''

The pakadoo point id.

Return values
array<string|int, mixed>|WP_Error

The pakadoo point address if existing.

get_addresses()

If you want to obtain a list of addresses, this is the way to go.

public get_addresses([array<string|int, mixed> $filter = [] ]) : array<string|int, mixed>|WP_Error

You can filter the addresses list using one or more of the following URL parameters:

first_name, e.g. 'first_name=Max' last_name, e.g. 'last_name=Mustermann' company, e.g. 'company=Example%20Company' care_of, e.g. 'care_of=Roger%20Receiver' street, e.g. 'street_no=Musterstraße' street_no, e.g. 'street_no=42' zip_code, e.g. 'zip_code=12345' state, e.g. 'state=CA' city, e.g. 'city=Musterstadt' country, e.g. 'country=DE' phone, e.g. 'phone=555-555' page, show page number x, e.g. 'page=2' per_page, show x number of shipments on a page (default & max: 100), e.g. 'per_page=25'

Parameters
$filter : array<string|int, mixed> = []

A list of filter criteria.

Return values
array<string|int, mixed>|WP_Error

A list of all created addresses.

get_carrier_list()

Get a list of carriers available for your account.

public get_carrier_list() : array<string|int, mixed>
Return values
array<string|int, mixed>

A list of all carriers available for your account.

get_carriers()

Get all carriers available for your shipcloud account.

public get_carriers() : array<string|int, mixed>|false
Return values
array<string|int, mixed>|false

get_current_shipment_status()

Getting the get current status of a certain shipment.

public get_current_shipment_status( $shipment_id) : array<string|int, mixed>|WP_Error
Response:
{
  "timestamp": "2021-10-14T15:56:39+02:00",
  "location": "Paderborn",
  "status": "package_delivered",
  "details": "Es wurde eine Sendung angelegt",
  "id": "4bff7566-33f4-4baa-84aa-9fda2d02b77c"
}
Parameters
$shipment_id :

The ID of the shipment asked for

Return values
array<string|int, mixed>|WP_Error

$tracking_status The tracking status of the given shipment

get_default_returns_address()

This is the default address that will be used for returns shipments when no address was specified using the 'to' attribute.

public get_default_returns_address() : array<string|int, mixed>|WP_Error
Return values
array<string|int, mixed>|WP_Error

The default returns address.

get_default_shipping_address()

This is the default address that will be used for shipments when no address was specified using the 'from' attribute.

public get_default_shipping_address() : array<string|int, mixed>
Return values
array<string|int, mixed>

The default shipping address.

get_invoice_address()

This is the address that a user has specified as being their invoice address.

public get_invoice_address() : array<string|int, mixed>|WP_Error
Return values
array<string|int, mixed>|WP_Error

The invoice address.

get_pickup_request()

Getting information about a certain pickup request.

public get_pickup_request([string $id = '' ]) : array<string|int, mixed>|bool
Parameters
$id : string = ''

The id attribute that was returned when creating the pickup request.

Return values
array<string|int, mixed>|bool

The pickup request if existing, false otherwise.

get_pickup_requests()

Getting a list of pickup requests.

public get_pickup_requests() : array<string|int, mixed>
Return values
array<string|int, mixed>

A list of pickup requests.

get_price()

Getting the price for a shipment

public get_price(string $carrier, array<string|int, mixed> $from, array<string|int, mixed> $to[, array<string|int, mixed> $package = [] ][, mixed $service = '' ]) : float|WP_Error
Parameters
$carrier : string
$from : array<string|int, mixed>
$to : array<string|int, mixed>
$package : array<string|int, mixed> = []
$service : mixed = ''
Return values
float|WP_Error

get_shipment()

If you want to obtain a certain shipment, this is the way to go.

public get_shipment([string $id = '' ]) : array<string|int, mixed>|WP_Error
Parameters
$id : string = ''

The id attribute that was returned when creating the shipment.

Return values
array<string|int, mixed>|WP_Error

The shipment if existing.

get_shipments()

If you want to obtain a list of shipments, this is the way to go.

public get_shipments([array<string|int, mixed> $filter = [] ]) : array<string|int, mixed>|WP_Error

You can filter the shipments list using one or more of the following URL parameters:

carrier, e.g. 'carrier=dhl'
carrier_tracking_no, e.g. 'carrier_tracking_no=43128000105'
created_at_gt, e.g. 'created_at_gt=20180712T1300Z'
created_at_lt, e.g. 'created_at_lt=20180712T1400Z'
page, show page number x, e.g. 'page=2'
per_page, show x number of shipments on a page (default & max: 100), e.g. 'per_page=25'
reference_number, e.g. 'reference_number=ref123456'
service, e.g. 'service=returns'
shipcloud_tracking_no, e.g. 'shipcloud_tracking_no=86afb143f9c9c0cfd4eb7a7c26a5c616585a6271'
shipment_type, e.g. 'shipment_type=prepared'
source, e.g. 'source=api'
tracking_status, e.g. 'tracking_status=out_for_delivery'
tracking_status_not, e.g. 'tracking_status_not=delivered'

shipment_type: Specifies the type of a shipment. The following types are available:

prepared: a shipment which was saved in shipcloud but doesn't have a shipping label yet
label_created: a shipment containing a shipping label.
tracking_only: a shipment that was imported via its carrier tracking number (see trackers for more details)

created_at_gt / created_at_lt: You can filter the list by using these parameters to specify a timerange to
find the shipments that were created during this time. The timestamp will be evaluated as ISO 8601 using the
following format: YYYYMMDDThhmmZ.

source: Filter shipments by platform they were created through. The following keys can be used:

api: a shipment created through our api
webui: a shipment created using the shipcloud ui
return_portal: a shipment created using the shipcloud return portal
Parameters
$filter : array<string|int, mixed> = []

A list of filter criteria.

Return values
array<string|int, mixed>|WP_Error

A list of all created shipments.

get_tracker()

Getting information about a certain tracker.

public get_tracker([string $id = '' ]) : array<string|int, mixed>|bool
Parameters
$id : string = ''

The id attribute that was returned when creating the tracker.

Return values
array<string|int, mixed>|bool

The tracker if existing, false otherwise.

update_shipment()

This method is to update an existing shipment.

public update_shipment([array<string|int, mixed> $data = [] ]) : array<string|int, mixed>|WP_Error
Parameters
$data : array<string|int, mixed> = []

The shipment to edit.

Return values
array<string|int, mixed>|WP_Error

Shipment labeling, tracking and pricing information.

add_admin_notice()

Output an admin notice.

private add_admin_notice(string $message[, string $type = 'info' ][, bool $dismissible = true ]) : void
Parameters
$message : string

Debug message.

$type : string = 'info'

Message type.

$dismissible : bool = true

Message type.

Return values
void

convert_data_array_to_address_api_object()

Converts address data array to Address.

private convert_data_array_to_address_api_object([array<string|int, mixed> $data = [] ]) : Address
Parameters
$data : array<string|int, mixed> = []

The address data

Return values
Address

convert_data_array_to_pickup_api_object()

Converts pickup data array to Pickup.

private convert_data_array_to_pickup_api_object([array<string|int, mixed> $data = [] ]) : Pickup
Parameters
$data : array<string|int, mixed> = []

The pickup data

Return values
Pickup

convert_data_array_to_shipment_api_object()

Converts shipment data array to Shipment.

private convert_data_array_to_shipment_api_object([array<string|int, mixed> $data = [] ]) : Shipment
Parameters
$data : array<string|int, mixed> = []

The shipment data

Return values
Shipment

convert_data_array_to_tracker_api_object()

Converts tracker data array to Tracker.

private convert_data_array_to_tracker_api_object([array<string|int, mixed> $data = [] ]) : Tracker
Parameters
$data : array<string|int, mixed> = []

The tracker data

Return values
Tracker

create_shipment_quote()

With this call you can find out how much we will charge you for a specific shipment.

private create_shipment_quote([array<string|int, mixed> $data = [] ]) : float|WP_Error
Parameters
$data : array<string|int, mixed> = []

The shipment data to get quote for.

Return values
float|WP_Error

An array with shipment quote if succeeded, false otherwise.

create_webhook()

If you want to create a webhook, this is the way to go.

private create_webhook() : string|bool
Return values
string|bool

The id of the created webhook, false otherwise.

get_latest_tracking_status()

Extracting latest tracking information of a certain shipment.

private get_latest_tracking_status([array<string|int, mixed> $tracking_events = [] ]) : array<string|int, mixed>|bool
Parameters
$tracking_events : array<string|int, mixed> = []

The tracking events of a certain shipment

Return values
array<string|int, mixed>|bool

The latest tracking information if available

get_service_display_name()

Getting service display name by service id.

private get_service_display_name(int $service_id) : string
Parameters
$service_id : int
Return values
string

handle_exception()

Handles Exception and converts it to WP_Error.

private handle_exception(Exception $e) : WP_Error
Parameters
$e : Exception

The exception thrown

Return values
WP_Error

log()

Output a debug message.

private log(string $message[, string $level = 'info' ][, mixed $context = [] ]) : void
Parameters
$message : string

Debug message.

$level : string = 'info'

Debug level.

$context : mixed = []

The Debug context.

Return values
void

Search results