@lacspace/shipping
Checkout-time shipping-rate calculator — flat / weight / price / item rate tables by zone, free-shipping thresholds, surcharges and handling, returning sorted method quotes. Integer minor units, zero-dependency, isomorphic.
npm i @lacspace/shippingUsage
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
resolveZonerateForMethodquoteShippingcheapestQuotefreeShippingRemainingShippingErrorKeywords
More in Commerce & Ledger
Headless, framework-agnostic shopping-cart engine — pure, immutable & serializable. Add/merge lines, set quantities, compute tax/discount/shipping totals in integer minor units. Isomorphic (Node, edge, browser).
@lacspace/inventoryStock-tracking engine that prevents overselling — reserve, release, commit & restock over a plain { onHand, reserved } state. Immutable, bring-your-own-store, throws before it oversells. Isomorphic.
@lacspace/commissionCommission & payout calculation engine — flat, percentage and marginal-tiered rules with min/cap, plus exact proportional split with remainder distribution. Integer minor units, zero floats. Isomorphic.
@lacspace/settlementSettlement, netting & reconciliation for multi-party payouts — net signed ledger entries per account, reconcile expected vs actual, and list payable positive balances. Integer minor units, pure functions. Isomorphic.
@lacspace/couponDiscount & coupon engine — percent, fixed and free-shipping codes with validity windows, minimum-subtotal, discount caps and usage limits. Integer minor units, no float drift. Zero-dependency, isomorphic.
@lacspace/taxVAT & sales-tax done right — exact integer minor-unit arithmetic (no float cents bugs), add/extract tax, inclusive & exclusive prices, compound taxes, half-up/bankers rounding. Isomorphic.