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

MethodReturnsPurpose
id()stringA short machine id, for example mycarrier
label()stringThe name shown to the shop
capabilities()string[]What the carrier can do, see below
methods( $return )arrayThe ways this return can be sent
points( $return, $query )arrayService points near the customer, or near a postcode or town
book( $return, $choice )arrayBooks the return shipment
label_pdf( $return )stringThe label as a PDF string, or ''
cancel( $return )boolCancels a booked shipment when the return is cancelled

Capabilities

ValueMeaning
quotemethods() returns prices
labelThe carrier books shipments and provides labels
pointsThe customer can choose a service point
pickupThe carrier can collect at the customer’s address
trackingThe carrier reports progress, see below
costThe 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:

KeyTypeDescription
okboolWhether the booking succeeded
messagestringAn error message to show the shop, when ok is false
carrierstringThe carrier’s name, for example PostNord
trackingstringThe tracking number
label_urlstringA link to the label, if the label is not served through label_pdf()
pickupstringPickup details, when the carrier collects
instructionsstringInstructions to the customer
pricefloatWhat 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' ),
) );
StateMeaning
in_transitThe parcel has been picked up or dropped off. An approved return moves to In transit
deliveredThe parcel has arrived at the shop. Fires north_return_manager_parcel_arrived
exceptionSomething 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 => false with 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.