Delivery Provider Plugins
Register custom delivery options by using a delivery factory. There can be multiple delivery adapters; for a given order, only the adapter of the configured delivery provider is invoked.
The factories are:
| Factory | For |
|---|---|
registerShippingDelivery | a SHIPPING provider |
registerPickUpDelivery | a PICKUP provider (with locations) |
registerDeliveryProvider | a generic provider — pick the type |
Example: pickup provider
import { registerPickUpDelivery } from '@unchainedshop/core';
registerPickUpDelivery({
adapterId: 'shop-pickup',
locations: [
{
_id: 'first-location-id',
name: 'first-location',
address: { addressLine: 'address-line', postalCode: '1234', countryCode: 'CH', city: 'Zurich' },
geoPoint: { latitude: 47.3769, longitude: 8.5417 },
},
],
// Trigger fulfilment; return false to keep the delivery OPEN
send: async (configuration, context) => {
await enqueueDeliveryWork({
type: 'MARK_ORDER_DELIVERED',
scheduled: new Date(Date.now() + 24 * 60 * 60 * 1000),
input: { orderDeliveryId: context.orderDelivery?._id },
});
return false; // not delivered yet
},
});
Example: shipping provider
import { registerShippingDelivery } from '@unchainedshop/core';
registerShippingDelivery({
adapterId: 'acme-courier',
estimatedDeliveryThroughput: async (warehousingThroughputTime) =>
warehousingThroughputTime + 2 * 24 * 60 * 60 * 1000,
send: async (configuration, context) => {
await acme.createShipment(context.order);
return true; // dispatched
},
});
Callback reference
| Option | Behavior |
|---|---|
send | any truthy result (true or a Work item) → delivery status becomes DELIVERED; false → stays OPEN (the order can still progress); throwing → the process is interrupted and the order stays CONFIRMED (avoid — see Fulfilment Process) |
active | enable/disable the adapter (default true) |
autoReleaseAllowed | auto-advance status vs require manual delivery confirmation |
estimatedDeliveryThroughput | estimated delivery time in ms |
locations (pickup) | available pickup points |
For full control of every
IDeliveryAdaptermethod, build the adapter directly and register it viapluginRegistry.register()— see Plugin System.
Related
- Plugin Factories — the delivery factories
- Delivery plugins — shipped delivery adapters