Return carriers
A return carrier connects a shipping service to North Return Manager. With a carrier, the shop can offer return shipping options in the return portal, book the return shipment when a return is approved, print the label and follow the parcel back. North Shipping Manager Premium uses this interface for Sendify, and you can use it to connect any other shipping service.
Without a carrier, North Return Manager still works: the customer sends the parcel themselves.
Register your carrier
Implement \NorthReturnManager\Carriers\Carrier and register it when North Return Manager has loaded. Reference the interface only inside the callback, so your plugin keeps working when North Return Manager is not installed.
add_action( 'north_return_manager_loaded', function ( int $api ) {
if ( 1 !== $api ) {
return; // Only register for the API version you were built for.
}
require_once __DIR__ . '/class-my-return-carrier.php';
add_filter( 'north_return_manager_carriers', function ( array $carriers ) {
$carriers['mycarrier'] = new My_Return_Carrier();
return $carriers;
} );
} );
The interface
| Method | Returns | Purpose |
|---|---|---|
id() | string | A short machine id, for example mycarrier |
label() | string | The name shown to the shop |
capabilities() | string[] | What the carrier can do, see below |
methods( $return ) | array | The ways this return can be sent |
points( $return, $query ) | array | Service points near the customer, or near a postcode or town |
book( $return, $choice ) | array | Books the return shipment |
label_pdf( $return ) | string | The label as a PDF string, or '' |
cancel( $return ) | bool | Cancels a booked shipment when the return is cancelled |
Capabilities
| Value | Meaning |
|---|---|
quote | methods() returns prices |
label | The carrier books shipments and provides labels |
points | The customer can choose a service point |
pickup | The carrier can collect at the customer’s address |
tracking | The carrier reports progress, see below |
cost | The carrier can tell what a booked shipment actually cost. Implement CostAware too |
methods()
Return one entry per way of sending:
return array(
array(
'id' => 'parcel_point',
'label' => 'Drop off at a service point',
'description' => 'Print the label and leave the parcel at a service point near you.',
'price' => 49.0, // What the customer pays, or null if the shop pays or the price is unknown.
'needs_point' => true, // The customer must choose a service point.
),
);
points()
Return service points as id, name, address and, if you have it, distance.
book()
$choice contains method and, when the method needs one, point. Return:
| Key | Type | Description |
|---|---|---|
ok | bool | Whether the booking succeeded |
message | string | An error message to show the shop, when ok is false |
carrier | string | The carrier’s name, for example PostNord |
tracking | string | The tracking number |
label_url | string | A link to the label, if the label is not served through label_pdf() |
pickup | string | Pickup details, when the carrier collects |
instructions | string | Instructions to the customer |
price | float | What the booking cost the shop, excluding the shop’s markup |
When you return price, the return shipping deduction follows the real cost. If the cost is higher than what the customer agreed to, the customer is asked to approve the new amount.
Report tracking
If your carrier lists tracking, report progress with an action:
do_action( 'north_return_manager_shipment_update', $return_id, 'in_transit', array(
'status' => 'IN_TRANSIT',
'created_at' => gmdate( 'c' ),
) );
| State | Meaning |
|---|---|
in_transit | The parcel has been picked up or dropped off. An approved return moves to In transit |
delivered | The parcel has arrived at the shop. Fires north_return_manager_parcel_arrived |
exception | Something went wrong. The shop sees it in the return’s history |
The event may also include description and location_name. They are shown only to the shop, never to the customer. If the carrier later charges more, for example for weight, include price and the return records the new cost.
Actual cost (optional)
Implement \NorthReturnManager\Carriers\CostAware and list cost in capabilities(). The return then shows a button that fetches what the booked shipment actually cost:
public function cost( \NorthReturnManager\ReturnRequest $return ): array {
return array( 'ok' => true, 'price' => 89.0, 'currency' => 'SEK' );
}
Check interface_exists( '\NorthReturnManager\Carriers\CostAware' ) before you implement it, so your carrier also works with older versions of North Return Manager.
Good practice
- Never block the return flow. If your service is down, return
ok => falsewith a clear message. The shop can then book by hand or let the customer send the parcel themselves. - Keep the customer’s data with the carrier. Send the customer’s address only to the shipping service that books the shipment.
- Keep the shop’s private addresses private. If the shop picks up at a secret address, never show it to the customer in labels, emails or tracking texts.
