Before you begin
You need the following:- A Mercur project with
@mercurjs/coreregistered throughwithMercur() - The id of any seller, product, or category you want to scope a rate to
1
Create a percentage rate
Run The workflow returns the created rates in input order. If you leave out
createCommissionRatesWorkflow with an array of rates. This seed script creates a 12% rate for apparel.src/scripts/seed-commission.ts
code, the module generates one from name with a random suffix, so set it when other code needs to find the rate by code.2
Run the script
Run the script with the Medusa CLI from your API app.A rate without rules matches every line, so it competes with the global rate until you scope it.
3
Scope the rate
Attach rules with The rate now matches only lines whose product has that type. See Batch-update commission rules for updates and deletes.
batchCommissionRulesWorkflow, passing the id of the rate you created.src/scripts/seed-commission.ts
Create a fixed rate with per-currency amounts
A fixed rate takes an amount per currency invalues, and value is the fallback. CreateCommissionRateDTO doesn’t declare values or rules, but the module creates both as nested records.
src/scripts/seed-commission.ts
values and rules keys. The result is a flat fee per line item for one seller: 2.5 in USD, 2 in EUR, and 3 in any other currency.
Change the global commission
The global rate is the one withis_default: true. Look it up, then update it with updateCommissionRatesWorkflow.
src/scripts/seed-commission.ts
include_shipping produces shipping lines.