← All packages

@lacspace/shipping

v1.2.0Commerce & Ledger0 deps

Checkout-time shipping-rate calculator — zone rate tables, weight-break brackets, dimensional/volumetric weight, flat/price/item strategies, free & discounted thresholds, surcharges + handling breakdowns, and sorted multi-method quotes with ETA. Integer minor units, zero-dependency, isomorphic.

npm i @lacspace/shipping

Usage

shipping.ts
import { quoteShipping, cheapestQuote } from "@lacspace/shipping";

const methods = [
  { id: "std", label: "Standard", strategy: "weight", freeOver: 500000, bands: [
    { min: 0, max: 1000, cost: 8000 }, { min: 1000, cost: 12000 },
  ] },
  { id: "exp", label: "Express", strategy: "flat", flat: 25000, etaDays: [1, 2] },
];

const quotes = quoteShipping(methods, { weight: 750, subtotal: 300000 });
// sorted cheapest-first: [{ methodId: "std", cost: 8000 }, { methodId: "exp", cost: 25000 }]
const best = cheapestQuote(methods, { weight: 750, subtotal: 600000 }); // std, free (over 5,000)

Exports 6

resolveZonerateForMethodquoteShippingcheapestQuotefreeShippingRemainingShippingError

Keywords

shippingshipping-ratesecommercecheckoutfree-shippingdelivery

More in Commerce & Ledger

@lacspace/cart

Headless, framework-agnostic shopping-cart engine — pure, immutable & serializable. Line-item options/add-ons, line & cart discounts (%/fixed), injectable tax hooks (inclusive/exclusive), a full totals breakdown, plus serialize/hydrate/merge — all in integer minor units. Isomorphic (Node, edge, browser).

@lacspace/inventory

Headless stock engine that prevents overselling — reserve/commit/restock over plain { onHand, reserved } state, plus multi-location transfers, reorder points, lot/expiry FIFO-FEFO allocation, and an append-only movements ledger with low-stock & expiring-soon reports. Immutable, bring-your-own-store, isomorphic.

@lacspace/commission

Commission & payout engine — flat/percent/marginal-tier/progressive-slab rules with caps & floors, composite and per-category rates, tax-on-commission (inclusive/exclusive), explicit rounding modes, and a marketplace split (platform + seller + affiliate) whose lines conserve the gross exactly. Integer minor units, zero floats. Isomorphic.

@lacspace/settlement

Settlement, netting & reconciliation for marketplace payouts — batch-settle transactions per payee, deduct commission/fees/tax, hold rolling reserves, schedule payout dates (skipping weekends & holidays) and build statements. Integer minor units, pure functions. Isomorphic.

@lacspace/coupon

Discount & coupon engine — percent, fixed, free-shipping, BOGO and tiered codes, with validity windows, total/per-user limits, first-order and product/category scope, a currency guard, safe coupon stacking and CSPRNG code generation. Integer minor units, no float drift. Zero-dependency, isomorphic.

@lacspace/tax

VAT & sales-tax done right — exact integer minor-unit arithmetic (no float cents bugs), add/extract tax (inclusive & exclusive), multiple & compound taxes with a labelled breakdown, category rate tables, reverse charge, and line-level vs invoice-level rounding. Isomorphic.