Skip to main content
Loads each order with its items, products, sellers, and shipping methods, evaluates the matching commission rates, and upserts a commission line per item and shipping method (delete-then-insert, so re-running is idempotent). Runs inside completeCartWithSplitOrdersWorkflow after orders are created, and again from the order-edit-confirmed subscriber on order edits, returns, claims, and exchanges.

Usage

import { refreshOrderCommissionLinesWorkflow } from "@mercurjs/core/workflows"

const { result } = await refreshOrderCommissionLinesWorkflow(container).run({
  input: { order_ids: ["order_123"] },
})

Input

order_ids
string[]
required
IDs of the orders to recompute commission lines for; fails if any order is not found.

Result

result
CommissionLineDTO[]
The upserted commission lines.
result[].item_id
string | null
The order line item the commission applies to.
result[].shipping_method_id
string | null
The shipping method the commission applies to.
result[].commission_rate_id
string | null
The rate that produced the line.
result[].code
string
Code of the applied rate.
result[].rate
number
Rate value applied.
result[].amount
number
Commission amount in the order currency.