Shipping

Onfleet local delivery for GoCommerce

A Go package that turns a shipment into an Onfleet task for the store’s own drivers. Not a carrier: no label, no waybill — a delivery task with the order on it, and a note to collect money when the order is unpaid.

What it does

The module registers “onfleet” as a fulfillment provider. An operator ships through the engine’s own POST /api/admin/create-fulfillment with the provider onfleet — the engine keeps the order’s state and its events, and the module only talks to Onfleet.

The package is plain about what Onfleet is not: it carries nothing. It dispatches a task to the store’s own drivers, so the tracking number recorded is Onfleet’s shortId — what finds the task in the dashboard — the carrier is “onfleet”, and there is no label, because a driver going to an address does not need one. It suits same-day and local delivery and, in the package’s words, it is the wrong module for anything that goes in the post.

In the admin it describes itself as “Dispatches your own drivers through Onfleet: every shipment becomes a delivery task.” One setting is required, the API key. No SDK: REST over Go’s standard library.

Configuration

Only the API key is required. Set it in Config from your own main(), or leave Config empty and type it under Settings › Shipping providers.

Onfleet module settings — 6 settings, 1 required
SettingEnvironment variableRequiredWhat it does
APIKey
API key
ONFLEET_API_KEY Yes An Onfleet API key, sent as the username of HTTP Basic auth with an empty password — which is how Onfleet authenticates.
AutoAssign
Auto-assign a driver
— No Asks Onfleet to pick a driver, by distance, as the task is created. Off by default: assigning somebody’s next two hours is a decision.
TeamID
Team ID
— No Scopes auto-assignment to one team. Only meaningful with AutoAssign.
ServiceTimeMinutes
Service time (minutes)
— No How long the driver is expected at the door. Zero leaves Onfleet’s own default.
BaseURL
API base URL
— No Overrides https://onfleet.com/api/v2, for tests. Empty for production.
Client — No Replaces the HTTP client, which otherwise times out after 30 seconds. Go only; not in the panel.

The module reads its Config struct, not the environment. The variable names are the ones the package’s own example or the reference binary uses; in your own main() you choose where each value comes from. Where a setting has a panel label, the admin’s settings drawer can hold it too, and a value typed there wins over Config.

Setting it up

  1. Get an API keyFrom Onfleet’s dashboard, under API & Webhooks, as the plugin’s own help text says.
  2. Install the moduleImport it and pass onfleet.New to gocommerce.New, as below — or run the reference binary with -carriers, which installs every carrier module idle.
  3. Decide on assignmentLeave auto-assign off to dispatch by hand in Onfleet, or switch it on, optionally for one team. Settings live in Config or under Settings › Shipping providers.
  4. Ship an orderPOST /api/admin/create-fulfillment with the order id and the provider onfleet. The task’s shortId is recorded as the tracking number; meta notes adds a line for the driver.

main.go

import (
	"os"

	"github.com/itswadesh/gocommerce/core"
	onfleet "github.com/itswadesh/gocommerce/ext/fulfill-onfleet"
)

app, err := gocommerce.New(cfg,
	onfleet.New(onfleet.Config{APIKey: os.Getenv("ONFLEET_API_KEY")}),
)

The package doc’s own example, with its imports; cfg is your gocommerce.Config. With an empty onfleet.Config the module installs idle and waits for the panel. Import path github.com/itswadesh/gocommerce/ext/fulfill-onfleet.

How it works

What it does not do

Read these before an order depends on it. No store is known to run GoCommerce in production yet, so these come from the code, not from anyone’s experience.

FAQ

Questions about the Onfleet module

What does the customer see?

Whatever Onfleet sends them: it texts the recipient its own tracking link. The store’s own order.shipped message still goes out through whichever notifier is installed, with the task’s shortId as the tracking number.

Does it handle cash on delivery?

It tells the driver. When the order is not paid, the task notes open with COLLECT, the currency and the order total. Marking the order paid afterwards is done in GoCommerce, as for any cash-on-delivery order.

Can I use it without writing Go?

Yes. The reference binary’s -carriers flag installs every carrier module with an empty Config. Switch Onfleet on under Settings › Shipping providers and paste the API key there.

Is this an Onfleet partnership?

No. The module calls Onfleet’s public API with a key you supply. Onfleet does not endorse GoCommerce, and no store is known to run this module in production yet.

Source

Everything on this page is read from ext/fulfill-onfleet in the GoCommerce repository, MIT licensed. When this page and the code disagree, the code is right and this page is out of date.Onfleet is a trademark of its owner; this module talks to its public API and implies no endorsement. See trademarks.

Try it against a store of your own

The one-command stack gives you GoCommerce’s API and admin on your own machine in minutes. Add this module to it and try it on test orders before a real one depends on it.

Chat on WhatsApp