Resolve the service
Resolve the service from the container withMercurModules.COMMISSION.
Generated methods
The service extendsMedusaService, so every model gets the standard methods. For CommissionRate they are:
The same set exists for
CommissionRule, CommissionRateValue, and CommissionLine, for example listCommissionRules, createCommissionRateValues, and retrieveCommissionLine.
Custom methods
The service overrides or adds these methods:getCommissionLines and getCommissionLinesBatch stamp the default provider’s id on any line without a provider_id. getCommissionLinesBatch falls back to one getCommissionLines call per context when the provider has no batch method.
Filter rates by scope type
scope_type filters rates by the dimensions their rules use, computed in the database. Pass one value, an array, or a comma-separated string. Several values are combined with OR, and an unknown value matches nothing.
Commission providers
A provider computes the lines from a calculation context. The module always registers the built-insystem provider, which implements the rule matching algorithm, and uses it unless you configure another one.
src/modules/tiered-commission/service.ts
identifier and getCommissionLines. It can add getCommissionLinesBatch(contexts) to load its data once per batch. The module doesn’t cap amount, so keep it within the item’s total yourself.
Export the class as a module provider so the commission module can register it.
src/modules/tiered-commission/index.ts
CommissionModuleOptions:
A single configured provider becomes the default without
is_default.