@mercurjs/docs 2.2.0-canary.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/README.md +24 -0
  2. package/content/blocks.mdx +209 -0
  3. package/content/learn/architecture.mdx +215 -0
  4. package/content/learn/attributes.mdx +89 -0
  5. package/content/learn/blocks.mdx +99 -0
  6. package/content/learn/commissions.mdx +175 -0
  7. package/content/learn/concepts.mdx +84 -0
  8. package/content/learn/installation.mdx +117 -0
  9. package/content/learn/introduction.mdx +71 -0
  10. package/content/learn/offers.mdx +78 -0
  11. package/content/learn/order-groups.mdx +114 -0
  12. package/content/learn/payouts.mdx +175 -0
  13. package/content/learn/product-requests.mdx +82 -0
  14. package/content/learn/products.mdx +79 -0
  15. package/content/learn/registry.mdx +155 -0
  16. package/content/learn/seller-members.mdx +62 -0
  17. package/content/learn/sellers.mdx +118 -0
  18. package/content/migration/from-1-x-to-2-0.mdx +152 -0
  19. package/content/migration/from-2-0-to-2-1.mdx +105 -0
  20. package/content/migration/overview.mdx +58 -0
  21. package/content/references/api/admin/commission-rates/batch-commission-rules.mdx +70 -0
  22. package/content/references/api/admin/commission-rates/create-commission-rate.mdx +95 -0
  23. package/content/references/api/admin/commission-rates/delete-commission-rate.mdx +40 -0
  24. package/content/references/api/admin/commission-rates/list-commission-rates.mdx +92 -0
  25. package/content/references/api/admin/commission-rates/retrieve-commission-rate.mdx +70 -0
  26. package/content/references/api/admin/commission-rates/update-commission-rate.mdx +84 -0
  27. package/content/references/api/admin/members/list-members.mdx +61 -0
  28. package/content/references/api/admin/offers/batch-create-offers.mdx +130 -0
  29. package/content/references/api/admin/offers/delete-offer.mdx +40 -0
  30. package/content/references/api/admin/offers/list-offers.mdx +106 -0
  31. package/content/references/api/admin/offers/retrieve-offer.mdx +82 -0
  32. package/content/references/api/admin/order-groups/list-order-groups.mdx +77 -0
  33. package/content/references/api/admin/order-groups/retrieve-order-group.mdx +56 -0
  34. package/content/references/api/admin/orders/get-order-commission-lines.mdx +65 -0
  35. package/content/references/api/admin/orders/get-order-order-group.mdx +56 -0
  36. package/content/references/api/admin/orders/list-orders.mdx +79 -0
  37. package/content/references/api/admin/payouts/list-payouts.mdx +75 -0
  38. package/content/references/api/admin/payouts/retrieve-payout.mdx +62 -0
  39. package/content/references/api/admin/product-attributes/create-attribute-value.mdx +76 -0
  40. package/content/references/api/admin/product-attributes/create-product-attribute.mdx +99 -0
  41. package/content/references/api/admin/product-attributes/delete-attribute-value.mdx +52 -0
  42. package/content/references/api/admin/product-attributes/delete-product-attribute.mdx +40 -0
  43. package/content/references/api/admin/product-attributes/list-product-attributes.mdx +91 -0
  44. package/content/references/api/admin/product-attributes/retrieve-product-attribute.mdx +81 -0
  45. package/content/references/api/admin/product-attributes/update-attribute-value.mdx +66 -0
  46. package/content/references/api/admin/product-attributes/update-product-attribute.mdx +76 -0
  47. package/content/references/api/admin/product-changes/cancel-product-change.mdx +68 -0
  48. package/content/references/api/admin/product-changes/confirm-product-change.mdx +47 -0
  49. package/content/references/api/admin/products/batch-product-attributes.mdx +96 -0
  50. package/content/references/api/admin/products/confirm-product.mdx +59 -0
  51. package/content/references/api/admin/products/create-product-variant.mdx +78 -0
  52. package/content/references/api/admin/products/create-product.mdx +169 -0
  53. package/content/references/api/admin/products/delete-product-variant.mdx +48 -0
  54. package/content/references/api/admin/products/delete-product.mdx +40 -0
  55. package/content/references/api/admin/products/list-product-variants.mdx +91 -0
  56. package/content/references/api/admin/products/list-products.mdx +109 -0
  57. package/content/references/api/admin/products/preview-product.mdx +78 -0
  58. package/content/references/api/admin/products/reject-product.mdx +59 -0
  59. package/content/references/api/admin/products/request-product-changes.mdx +59 -0
  60. package/content/references/api/admin/products/retrieve-product-variant.mdx +73 -0
  61. package/content/references/api/admin/products/retrieve-product.mdx +96 -0
  62. package/content/references/api/admin/products/set-product-sellers.mdx +47 -0
  63. package/content/references/api/admin/products/update-product-variant.mdx +89 -0
  64. package/content/references/api/admin/products/update-product.mdx +133 -0
  65. package/content/references/api/admin/sellers/add-seller-member.mdx +63 -0
  66. package/content/references/api/admin/sellers/approve-seller.mdx +54 -0
  67. package/content/references/api/admin/sellers/create-seller.mdx +100 -0
  68. package/content/references/api/admin/sellers/delete-member-invite.mdx +42 -0
  69. package/content/references/api/admin/sellers/delete-professional-details.mdx +52 -0
  70. package/content/references/api/admin/sellers/invite-seller-member.mdx +63 -0
  71. package/content/references/api/admin/sellers/list-member-invites.mdx +71 -0
  72. package/content/references/api/admin/sellers/list-seller-members.mdx +71 -0
  73. package/content/references/api/admin/sellers/list-seller-products.mdx +85 -0
  74. package/content/references/api/admin/sellers/list-sellers.mdx +96 -0
  75. package/content/references/api/admin/sellers/remove-seller-member.mdx +42 -0
  76. package/content/references/api/admin/sellers/resend-member-invite.mdx +55 -0
  77. package/content/references/api/admin/sellers/retrieve-seller.mdx +81 -0
  78. package/content/references/api/admin/sellers/suspend-seller.mdx +60 -0
  79. package/content/references/api/admin/sellers/terminate-seller.mdx +60 -0
  80. package/content/references/api/admin/sellers/unsuspend-seller.mdx +52 -0
  81. package/content/references/api/admin/sellers/unterminate-seller.mdx +52 -0
  82. package/content/references/api/admin/sellers/update-seller.mdx +83 -0
  83. package/content/references/api/admin/sellers/upsert-payment-details.mdx +88 -0
  84. package/content/references/api/admin/sellers/upsert-professional-details.mdx +78 -0
  85. package/content/references/api/admin/sellers/upsert-seller-address.mdx +91 -0
  86. package/content/references/api/admin.mdx +134 -0
  87. package/content/references/api/conventions.mdx +109 -0
  88. package/content/references/api/store/carts/add-line-item.mdx +115 -0
  89. package/content/references/api/store/carts/add-shipping-methods.mdx +84 -0
  90. package/content/references/api/store/carts/apply-promotions.mdx +83 -0
  91. package/content/references/api/store/carts/complete-cart.mdx +98 -0
  92. package/content/references/api/store/offers/list-offers.mdx +161 -0
  93. package/content/references/api/store/offers/retrieve-offer.mdx +112 -0
  94. package/content/references/api/store/order-groups/list-order-groups.mdx +105 -0
  95. package/content/references/api/store/order-groups/retrieve-order-group.mdx +78 -0
  96. package/content/references/api/store/product-attributes/list-product-attributes.mdx +134 -0
  97. package/content/references/api/store/product-attributes/retrieve-product-attribute.mdx +78 -0
  98. package/content/references/api/store/product-categories/list-product-categories.mdx +126 -0
  99. package/content/references/api/store/product-categories/retrieve-product-category.mdx +79 -0
  100. package/content/references/api/store/products/list-products.mdx +184 -0
  101. package/content/references/api/store/products/retrieve-product.mdx +107 -0
  102. package/content/references/api/store/search/search.mdx +136 -0
  103. package/content/references/api/store/sellers/list-sellers.mdx +105 -0
  104. package/content/references/api/store/sellers/retrieve-seller.mdx +62 -0
  105. package/content/references/api/store/shipping-options/list-shipping-options.mdx +74 -0
  106. package/content/references/api/store.mdx +67 -0
  107. package/content/references/api/vendor/members/accept-member-invite.mdx +65 -0
  108. package/content/references/api/vendor/members/retrieve-current-member.mdx +51 -0
  109. package/content/references/api/vendor/members/update-current-member.mdx +70 -0
  110. package/content/references/api/vendor/offers/batch-create-offers.mdx +123 -0
  111. package/content/references/api/vendor/offers/batch-offer-inventory-items.mdx +103 -0
  112. package/content/references/api/vendor/offers/create-offer.mdx +141 -0
  113. package/content/references/api/vendor/offers/delete-offer.mdx +51 -0
  114. package/content/references/api/vendor/offers/list-offers.mdx +125 -0
  115. package/content/references/api/vendor/offers/retrieve-offer.mdx +74 -0
  116. package/content/references/api/vendor/offers/update-offer.mdx +82 -0
  117. package/content/references/api/vendor/orders/cancel-fulfillment.mdx +63 -0
  118. package/content/references/api/vendor/orders/cancel-order.mdx +56 -0
  119. package/content/references/api/vendor/orders/complete-order.mdx +55 -0
  120. package/content/references/api/vendor/orders/create-fulfillment.mdx +76 -0
  121. package/content/references/api/vendor/orders/create-shipment.mdx +99 -0
  122. package/content/references/api/vendor/orders/get-order-commission-lines.mdx +66 -0
  123. package/content/references/api/vendor/orders/list-order-changes.mdx +75 -0
  124. package/content/references/api/vendor/orders/list-orders.mdx +103 -0
  125. package/content/references/api/vendor/orders/mark-fulfillment-delivered.mdx +62 -0
  126. package/content/references/api/vendor/orders/preview-order.mdx +65 -0
  127. package/content/references/api/vendor/orders/retrieve-order.mdx +84 -0
  128. package/content/references/api/vendor/payout-accounts/create-onboarding.mdx +68 -0
  129. package/content/references/api/vendor/payout-accounts/create-payout-account.mdx +59 -0
  130. package/content/references/api/vendor/payout-accounts/retrieve-payout-account-by-id.mdx +60 -0
  131. package/content/references/api/vendor/payout-accounts/retrieve-payout-account.mdx +77 -0
  132. package/content/references/api/vendor/payouts/list-payouts.mdx +90 -0
  133. package/content/references/api/vendor/payouts/retrieve-payout.mdx +63 -0
  134. package/content/references/api/vendor/product-attributes/list-product-attributes.mdx +135 -0
  135. package/content/references/api/vendor/product-attributes/retrieve-product-attribute.mdx +71 -0
  136. package/content/references/api/vendor/product-variants/list-variants.mdx +136 -0
  137. package/content/references/api/vendor/products/batch-product-attributes.mdx +104 -0
  138. package/content/references/api/vendor/products/cancel-product-change.mdx +62 -0
  139. package/content/references/api/vendor/products/create-product-variant.mdx +92 -0
  140. package/content/references/api/vendor/products/create-product.mdx +197 -0
  141. package/content/references/api/vendor/products/delete-product-variant.mdx +68 -0
  142. package/content/references/api/vendor/products/delete-product.mdx +62 -0
  143. package/content/references/api/vendor/products/list-product-variants.mdx +114 -0
  144. package/content/references/api/vendor/products/list-products.mdx +163 -0
  145. package/content/references/api/vendor/products/preview-product.mdx +61 -0
  146. package/content/references/api/vendor/products/retrieve-product-variant.mdx +76 -0
  147. package/content/references/api/vendor/products/retrieve-product.mdx +69 -0
  148. package/content/references/api/vendor/products/update-product-variant.mdx +104 -0
  149. package/content/references/api/vendor/products/update-product.mdx +148 -0
  150. package/content/references/api/vendor/sellers/create-seller.mdx +150 -0
  151. package/content/references/api/vendor/sellers/delete-professional-details.mdx +54 -0
  152. package/content/references/api/vendor/sellers/invite-seller-member.mdx +67 -0
  153. package/content/references/api/vendor/sellers/list-member-invites.mdx +82 -0
  154. package/content/references/api/vendor/sellers/list-seller-members.mdx +80 -0
  155. package/content/references/api/vendor/sellers/list-sellers.mdx +71 -0
  156. package/content/references/api/vendor/sellers/remove-seller-member.mdx +48 -0
  157. package/content/references/api/vendor/sellers/retrieve-current-seller-member.mdx +59 -0
  158. package/content/references/api/vendor/sellers/retrieve-current-seller.mdx +69 -0
  159. package/content/references/api/vendor/sellers/select-seller.mdx +44 -0
  160. package/content/references/api/vendor/sellers/update-current-seller.mdx +108 -0
  161. package/content/references/api/vendor/sellers/update-member-role.mdx +51 -0
  162. package/content/references/api/vendor/sellers/upsert-payment-details.mdx +74 -0
  163. package/content/references/api/vendor/sellers/upsert-professional-details.mdx +70 -0
  164. package/content/references/api/vendor/sellers/upsert-seller-address.mdx +81 -0
  165. package/content/references/api/vendor.mdx +150 -0
  166. package/content/references/configuration.mdx +155 -0
  167. package/content/references/modules/commission.mdx +106 -0
  168. package/content/references/modules/custom-fields.mdx +45 -0
  169. package/content/references/modules/media.mdx +55 -0
  170. package/content/references/modules/offer.mdx +64 -0
  171. package/content/references/modules/payout.mdx +121 -0
  172. package/content/references/modules/product-attribute.mdx +111 -0
  173. package/content/references/modules/product-edit.mdx +80 -0
  174. package/content/references/modules/search.mdx +112 -0
  175. package/content/references/modules/seller.mdx +175 -0
  176. package/content/references/overview.mdx +70 -0
  177. package/content/references/workflows/cart/add-seller-shipping-method-to-cart.mdx +44 -0
  178. package/content/references/workflows/cart/complete-cart-with-split-orders.mdx +36 -0
  179. package/content/references/workflows/cart/list-seller-shipping-options-for-cart.mdx +39 -0
  180. package/content/references/workflows/cart/update-cart-seller-promotions.mdx +42 -0
  181. package/content/references/workflows/commission/batch-commission-rules.mdx +45 -0
  182. package/content/references/workflows/commission/create-commission-rates.mdx +41 -0
  183. package/content/references/workflows/commission/delete-commission-rates.mdx +34 -0
  184. package/content/references/workflows/commission/refresh-order-commission-lines.mdx +30 -0
  185. package/content/references/workflows/commission/update-commission-rates.mdx +35 -0
  186. package/content/references/workflows/media/set-category-images.mdx +41 -0
  187. package/content/references/workflows/media/set-collection-images.mdx +41 -0
  188. package/content/references/workflows/member/accept-member-invite.mdx +33 -0
  189. package/content/references/workflows/member/add-seller-member.mdx +30 -0
  190. package/content/references/workflows/member/create-member-invites.mdx +34 -0
  191. package/content/references/workflows/member/delete-member-invite.mdx +24 -0
  192. package/content/references/workflows/member/remove-seller-member.mdx +28 -0
  193. package/content/references/workflows/member/resend-member-invite.mdx +28 -0
  194. package/content/references/workflows/member/update-member-role.mdx +28 -0
  195. package/content/references/workflows/member/update-member.mdx +35 -0
  196. package/content/references/workflows/offer/batch-offer-inventory-items.mdx +58 -0
  197. package/content/references/workflows/offer/create-offers.mdx +63 -0
  198. package/content/references/workflows/offer/delete-offers.mdx +35 -0
  199. package/content/references/workflows/offer/update-offers.mdx +51 -0
  200. package/content/references/workflows/order/cancel-order-fulfillment.mdx +34 -0
  201. package/content/references/workflows/order/confirm-claim-request.mdx +25 -0
  202. package/content/references/workflows/order/confirm-exchange-request.mdx +25 -0
  203. package/content/references/workflows/order/confirm-order-edit-request.mdx +25 -0
  204. package/content/references/workflows/order/confirm-return-receive.mdx +25 -0
  205. package/content/references/workflows/order/create-order-fulfillment.mdx +45 -0
  206. package/content/references/workflows/order-group/get-order-group-detail.mdx +29 -0
  207. package/content/references/workflows/order-group/get-order-groups-list.mdx +36 -0
  208. package/content/references/workflows/overview.mdx +72 -0
  209. package/content/references/workflows/payout/create-onboarding.mdx +36 -0
  210. package/content/references/workflows/payout/create-payout-account.mdx +33 -0
  211. package/content/references/workflows/payout/create-payout.mdx +30 -0
  212. package/content/references/workflows/payout/process-payout-for-webhook.mdx +32 -0
  213. package/content/references/workflows/product/confirm-products.mdx +46 -0
  214. package/content/references/workflows/product/create-products.mdx +63 -0
  215. package/content/references/workflows/product/link-sellers-to-product-category.mdx +40 -0
  216. package/content/references/workflows/product/link-sellers-to-product.mdx +40 -0
  217. package/content/references/workflows/product/reject-product.mdx +46 -0
  218. package/content/references/workflows/product/request-product-change.mdx +46 -0
  219. package/content/references/workflows/product-attribute/add-product-attributes-to-product.mdx +49 -0
  220. package/content/references/workflows/product-attribute/create-and-link-product-attributes-to-product.mdx +46 -0
  221. package/content/references/workflows/product-attribute/create-product-attribute-values.mdx +43 -0
  222. package/content/references/workflows/product-attribute/create-product-attributes.mdx +56 -0
  223. package/content/references/workflows/product-attribute/delete-product-attribute-values.mdx +30 -0
  224. package/content/references/workflows/product-attribute/delete-product-attributes.mdx +30 -0
  225. package/content/references/workflows/product-attribute/remove-product-attributes-from-product.mdx +29 -0
  226. package/content/references/workflows/product-attribute/update-product-attribute-values.mdx +44 -0
  227. package/content/references/workflows/product-attribute/update-product-attributes-on-product.mdx +41 -0
  228. package/content/references/workflows/product-attribute/update-product-attributes.mdx +48 -0
  229. package/content/references/workflows/product-attribute/upsert-product-attribute-values.mdx +43 -0
  230. package/content/references/workflows/product-edit/auto-confirm-product-change.mdx +39 -0
  231. package/content/references/workflows/product-edit/cancel-product-change.mdx +49 -0
  232. package/content/references/workflows/product-edit/confirm-product-change.mdx +57 -0
  233. package/content/references/workflows/product-edit/create-product-change.mdx +72 -0
  234. package/content/references/workflows/product-edit/reject-product-change.mdx +54 -0
  235. package/content/references/workflows/product-edit/stage-product-change.mdx +75 -0
  236. package/content/references/workflows/seller/approve-seller.mdx +34 -0
  237. package/content/references/workflows/seller/create-seller-account.mdx +59 -0
  238. package/content/references/workflows/seller/create-seller-defaults.mdx +22 -0
  239. package/content/references/workflows/seller/create-sellers.mdx +65 -0
  240. package/content/references/workflows/seller/delete-seller-professional-details.mdx +37 -0
  241. package/content/references/workflows/seller/delete-sellers.mdx +24 -0
  242. package/content/references/workflows/seller/invite-seller.mdx +28 -0
  243. package/content/references/workflows/seller/suspend-seller.mdx +35 -0
  244. package/content/references/workflows/seller/terminate-seller.mdx +35 -0
  245. package/content/references/workflows/seller/unsuspend-seller.mdx +34 -0
  246. package/content/references/workflows/seller/unterminate-seller.mdx +34 -0
  247. package/content/references/workflows/seller/update-seller-address.mdx +55 -0
  248. package/content/references/workflows/seller/update-seller-payment-details.mdx +52 -0
  249. package/content/references/workflows/seller/update-seller-professional-details.mdx +48 -0
  250. package/content/references/workflows/seller/update-sellers.mdx +57 -0
  251. package/content/resources/ai/llms.mdx +74 -0
  252. package/content/resources/ai/mcp.mdx +152 -0
  253. package/content/resources/ai/overview.mdx +97 -0
  254. package/content/resources/customization/custom-fields.mdx +182 -0
  255. package/content/resources/customization/extend-a-workflow.mdx +39 -0
  256. package/content/resources/customization/extending-panels.mdx +309 -0
  257. package/content/resources/deployment/medusa-cloud.mdx +167 -0
  258. package/content/resources/integrations/notifications.mdx +39 -0
  259. package/content/resources/integrations/search.mdx +122 -0
  260. package/content/resources/integrations/stripe-connect.mdx +395 -0
  261. package/content/resources/tutorials/add-a-block.mdx +74 -0
  262. package/content/resources/tutorials/attributes-and-variant-axes.mdx +111 -0
  263. package/content/resources/tutorials/build-a-block.mdx +134 -0
  264. package/content/resources/tutorials/configure-commissions.mdx +127 -0
  265. package/content/resources/tutorials/custom-api-route.mdx +142 -0
  266. package/content/resources/tutorials/custom-panel-page.mdx +78 -0
  267. package/content/resources/tutorials/first-marketplace.mdx +45 -0
  268. package/content/resources/tutorials/handle-product-requests.mdx +80 -0
  269. package/content/resources/tutorials/import-export-products.mdx +96 -0
  270. package/content/resources/tutorials/master-products-and-offers.mdx +89 -0
  271. package/content/resources/tutorials/recompose-a-page.mdx +129 -0
  272. package/content/resources/tutorials/replace-panel-components.mdx +116 -0
  273. package/content/resources/tutorials/seller-payouts-stripe.mdx +89 -0
  274. package/content/telemetry.mdx +67 -0
  275. package/content/tools/api-client.mdx +155 -0
  276. package/content/tools/cli.mdx +196 -0
  277. package/content/tools/dashboard-sdk.mdx +35 -0
  278. package/content/user-guide/admin/overview.mdx +23 -0
  279. package/content/user-guide/admin/stores.mdx +193 -0
  280. package/content/user-guide/vendor/overview.mdx +23 -0
  281. package/content/user-guide/vendor/stores.mdx +209 -0
  282. package/llms.txt +307 -0
  283. package/package.json +33 -0
@@ -0,0 +1,175 @@
1
+ ---
2
+ title: "Commission"
3
+ description: "How marketplace commissions work in Mercur — rates, rules, the matching algorithm, and commission lines."
4
+ ---
5
+
6
+ Commissions are how the marketplace earns revenue. Rather than storing a single commission percentage, Mercur uses a **rule-based system** where commission rates are matched to order line items based on configurable conditions, with a global default as the fallback.
7
+
8
+ ## Commission rates
9
+
10
+ A **CommissionRate** defines how much commission the marketplace takes and when it applies.
11
+
12
+ | Field | Description |
13
+ |-------|-------------|
14
+ | `name` | Human-readable name (e.g. "Electronics Commission") |
15
+ | `code` | Unique system identifier |
16
+ | `type` | `fixed` (flat amount) or `percentage` |
17
+ | `value` | The percentage, or the flat amount used when no per-currency value matches |
18
+ | `values` | Per-currency amounts for `fixed` rates (`currency_code` + `amount`) |
19
+ | `include_tax` | Include tax in the base amount for calculation |
20
+ | `include_shipping` | Whether shipping methods are also commissioned (global rate only) |
21
+ | `is_default` | Marks the **global commission** — the fallback applied when no scoped rate matches |
22
+ | `is_enabled` | Disabled rates are skipped entirely |
23
+
24
+ <Info>
25
+ `percentage` rates use the scalar `value`. `fixed` rates read the per-currency `values` list and fall back to `value` when the order's currency has no entry.
26
+ </Info>
27
+
28
+ ## Commission rules
29
+
30
+ Rules determine **when** a rate applies. Each rule has a `reference` (the dimension) and a `reference_id` (the value to match):
31
+
32
+ | Reference | Matches items whose product… |
33
+ |-----------|------------------------------|
34
+ | `product` | is that specific product |
35
+ | `product_type` | has that product type |
36
+ | `product_collection` | belongs to that collection |
37
+ | `product_category` | belongs to that category |
38
+ | `seller` | is sold by that seller |
39
+
40
+ A rate with **no rules** matches everything — that's what makes the default rate a catch-all.
41
+
42
+ ### The matching algorithm
43
+
44
+ For each line item:
45
+
46
+ 1. **Group** the rate's rules by dimension (`reference`).
47
+ 2. A rate matches when **every dimension group has at least one matching rule** — AND across dimensions, OR within a dimension. Example: a rate with rules `seller: A` and `product_category: electronics` matches only electronics sold by seller A; a rate with two `product_category` rules matches either category.
48
+ 3. Among all matching rates, the **most specific wins** — the rate scoping on the largest number of distinct dimensions.
49
+ 4. Ties break deterministically to the **oldest rate**.
50
+
51
+ **Example configuration:**
52
+
53
+ | Rate | Rules | Type | Value | Matches |
54
+ |------|-------|------|-------|---------|
55
+ | Premium seller electronics | `seller: slr_abc` + `product_category: electronics` | Percentage | 8% | Electronics from that seller (2 dimensions — most specific) |
56
+ | Electronics commission | `product_category: electronics` | Percentage | 12% | Other sellers' electronics (1 dimension) |
57
+ | Global commission | _(none, `is_default`)_ | Percentage | 15% | Everything else |
58
+
59
+ An electronics item from seller `slr_abc` gets 8% — the two-dimension rate beats the one-dimension category rate, regardless of creation order.
60
+
61
+ ## The calculation pipeline
62
+
63
+ The `getCommissionLines` step calculates commissions when an order is placed:
64
+
65
+ 1. **Load** all enabled rates with their rules and per-currency values. Rates pinned to a `currency_code` apply only to orders in that currency.
66
+ 2. **Match items** — for each line item, find matching rates and pick the most specific (see above).
67
+ 3. **Calculate** — the base amount is the item subtotal, plus tax when `include_tax` is on. Percentage: `(base × value) / 100`. Fixed: the per-currency amount.
68
+ 4. **Shipping** — governed solely by the **global commission**: when its `include_shipping` flag is on, each shipping method gets a commission line calculated from the global rate.
69
+ 5. **Output** — one `CommissionLine` per commissioned item and shipping method.
70
+
71
+ <Info>
72
+ All commission calculations use `BigNumber` arithmetic for precision. This is critical for financial accuracy — standard floating-point math can introduce rounding errors.
73
+ </Info>
74
+
75
+ ## API examples
76
+
77
+ ### Set up the global commission (Admin API)
78
+
79
+ ```bash
80
+ curl -X POST http://localhost:9000/admin/commission-rates \
81
+ -H "Authorization: Bearer <admin-token>" \
82
+ -H "Content-Type: application/json" \
83
+ -d '{
84
+ "name": "Global Commission",
85
+ "code": "global",
86
+ "type": "percentage",
87
+ "value": 15,
88
+ "is_default": true,
89
+ "include_shipping": true
90
+ }'
91
+ ```
92
+
93
+ ### Create a scoped rate with rules (Admin API)
94
+
95
+ ```bash
96
+ curl -X POST http://localhost:9000/admin/commission-rates \
97
+ -H "Authorization: Bearer <admin-token>" \
98
+ -H "Content-Type: application/json" \
99
+ -d '{
100
+ "name": "Electronics Commission",
101
+ "code": "electronics",
102
+ "type": "percentage",
103
+ "value": 12,
104
+ "rules": [
105
+ { "reference": "product_category", "reference_id": "pcat_electronics" }
106
+ ]
107
+ }'
108
+ ```
109
+
110
+ ### Create a fixed rate with per-currency amounts
111
+
112
+ ```bash
113
+ curl -X POST http://localhost:9000/admin/commission-rates \
114
+ -H "Authorization: Bearer <admin-token>" \
115
+ -H "Content-Type: application/json" \
116
+ -d '{
117
+ "name": "Flat Listing Fee",
118
+ "code": "flat-fee",
119
+ "type": "fixed",
120
+ "value": 2,
121
+ "values": [
122
+ { "currency_code": "usd", "amount": 2 },
123
+ { "currency_code": "eur", "amount": 1.8 }
124
+ ],
125
+ "rules": [
126
+ { "reference": "seller", "reference_id": "slr_abc123" }
127
+ ]
128
+ }'
129
+ ```
130
+
131
+ ### List commission rates
132
+
133
+ ```bash
134
+ curl http://localhost:9000/admin/commission-rates \
135
+ -H "Authorization: Bearer <admin-token>"
136
+ ```
137
+
138
+ ## Commission lines
139
+
140
+ A **CommissionLine** is the calculated commission for a single line item or shipping method:
141
+
142
+ | Field | Description |
143
+ |-------|-------------|
144
+ | `item_id` | The order line item (null for shipping lines) |
145
+ | `shipping_method_id` | The shipping method (null for item lines) |
146
+ | `commission_rate_id` | The rate that was applied |
147
+ | `code` | Code of the applied rate |
148
+ | `rate` | The rate value used |
149
+ | `amount` | The calculated commission amount |
150
+
151
+ Commission lines are linked to order line items via a **read-only link**, so an order's items can be queried together with their commission data in a single request.
152
+
153
+ ## How commission connects to payouts
154
+
155
+ Commission lines are the bridge between orders and seller earnings:
156
+
157
+ 1. An order is completed → commission lines are calculated for each item
158
+ 2. When the order is credited to the seller's payout account, the total commission is subtracted:
159
+ ```
160
+ seller_earnings = order.total - sum(commission_line.amount)
161
+ ```
162
+ 3. The marketplace retains the commission amount
163
+
164
+ This separation means commission rates can be changed at any time without affecting already-calculated orders — the `CommissionLine` records serve as a permanent audit trail.
165
+
166
+ ## Next steps
167
+
168
+ <CardGroup cols={2}>
169
+ <Card title="Payouts" href="/rc/learn/payouts">
170
+ How seller earnings settle after commission.
171
+ </Card>
172
+ <Card title="Order Groups" href="/rc/learn/order-groups">
173
+ The per-seller orders commissions are calculated on.
174
+ </Card>
175
+ </CardGroup>
@@ -0,0 +1,84 @@
1
+ ---
2
+ title: "Concepts"
3
+ description: "Core concepts behind Mercur — from the Medusa foundation to blocks, panels, and the registry."
4
+ ---
5
+
6
+ Mercur is built on a small set of concepts. Familiarity with these establishes a common language when working with the platform.
7
+
8
+ ## Medusa
9
+
10
+ [MedusaJS](https://medusajs.com) is the open-source commerce framework that powers Mercur's foundation. It handles products, pricing, carts, orders, payments, fulfillment, and promotions. Mercur does not replace any of this — it extends Medusa with marketplace-specific logic using Medusa's own extension model.
11
+
12
+ ## Admin Panel
13
+
14
+ The admin panel is a React application for **marketplace operators**. It provides a dashboard to manage sellers, configure commission rates, moderate product requests, handle disputes, and monitor the overall marketplace. It is built with [Medusa UI](https://docs.medusajs.com/ui) components and can be extended with custom pages and components through the [Dashboard SDK](#dashboard-sdk).
15
+
16
+ ## Vendor Portal
17
+
18
+ The vendor portal is a React application for **sellers**. Sellers use it to manage their products, process orders, configure shipping, track payouts, and handle returns. Like the admin panel, it is built on the Dashboard SDK and can be fully customized.
19
+
20
+ ## Storefront
21
+
22
+ The storefront is the **customer-facing** application. It can be built with any frontend technology that consumes the Store API — Next.js, Remix, or any other framework. Mercur provides a ready-made storefront template to start from.
23
+
24
+ ## API Routes
25
+
26
+ Mercur exposes three sets of HTTP endpoints:
27
+
28
+ - **Admin API** (`/admin/*`) — Platform administration
29
+ - **Vendor API** (`/vendor/*`) — Seller operations
30
+ - **Store API** (`/store/*`) — Customer-facing storefront
31
+
32
+ Each route is composed of a handler, middleware, query configuration, and validators.
33
+
34
+ ## Core Plugin
35
+
36
+ The core plugin (`@mercurjs/core`) is the main package that contains all of Mercur's marketplace logic — modules, links, workflows, API routes, subscribers, and providers. It is installed as a standard MedusaJS plugin and serves as the foundation that blocks extend.
37
+
38
+ ## Modules
39
+
40
+ Modules encapsulate data models and business logic for a specific domain. Each module is self-contained with its own models, service, and migrations. Mercur's marketplace modules include Seller, Commission, Offer, Payout, Product Attribute, Product Edit, Media, Custom Fields, and Search. They communicate through [Links](#links) and [Workflows](#workflows), never directly. Additional domains — such as Reviews — ship as installable [blocks](#blocks) from the registry rather than inside the core plugin.
41
+
42
+ ## Master Products
43
+
44
+ Products form a single **shared catalog** for the whole marketplace — a product is not owned by the seller who created it. Sellers gain the right to sell a product through eligibility assignments and sell it through [offers](#offers). See [Products](/rc/learn/products).
45
+
46
+ ## Offers
47
+
48
+ An offer is a seller's sellable listing against a master product: their own SKU, price, inventory, and shipping profile. Many sellers can hold competing offers on the same product. See [Offers](/rc/learn/offers).
49
+
50
+ ## Product Attributes
51
+
52
+ A typed, operator-managed attribute catalog (select, text, unit, toggle) that products reference for structured data and storefront filtering. Variant-axis attributes are backed by Medusa's native global product options. See [Product Attributes](/rc/learn/attributes).
53
+
54
+ ## Product Requests
55
+
56
+ Vendor product submissions and edits flow through a reviewable change-request pipeline — the operator confirms, declines, or requests revisions before anything touches the shared catalog. See [Product Requests & Approvals](/rc/learn/product-requests).
57
+
58
+ ## Links
59
+
60
+ Links define relationships between Mercur modules and Medusa core entities without modifying either side. For example, a link connects a Medusa Product to a Mercur Seller — this is how the system knows which sellers are eligible to sell which products.
61
+
62
+ ## Workflows
63
+
64
+ Workflows coordinate multi-step operations across modules. They support compensation (automatic rollback on failure) and hooks (extension points for custom logic). For example, the checkout workflow splits a cart by seller, creates separate orders, allocates payments, and calculates commissions — all as a single atomic operation.
65
+
66
+ ## Blocks
67
+
68
+ Blocks are the unit of distribution in Mercur. Each block is a self-contained piece of functionality — a module, a workflow, an API route, a link, or a UI extension. When you install a block, the CLI copies its source code directly into your project. You own every line and can modify anything.
69
+
70
+ ## Registry
71
+
72
+ A registry is a collection of blocks available for installation. The official Mercur registry (`@mercurjs`) provides all marketplace blocks. You can also create and host [custom registries](/rc/tools/cli#custom-registries) for your own blocks.
73
+
74
+ ## CLI
75
+
76
+ The [Mercur CLI](/rc/tools/cli) (`@mercurjs/cli@rc`) manages your project — scaffolding from templates, installing blocks, searching registries, generating types, and diffing local changes against upstream versions.
77
+
78
+ ## Dashboard SDK
79
+
80
+ The [Dashboard SDK](/rc/tools/dashboard-sdk) (`@mercurjs/dashboard-sdk`) is a Vite plugin shared by the admin panel and vendor portal. It provides file-based routing, automatic navigation generation, component overrides, and i18n support.
81
+
82
+ ## API Client
83
+
84
+ The [API Client](/rc/tools/api-client) (`@mercurjs/client`) provides type-safe access to all Mercur API endpoints. Types are generated from your actual API routes using `bunx @mercurjs/cli@rc codegen`, so requests and responses are always in sync with your backend.
@@ -0,0 +1,117 @@
1
+ ---
2
+ title: "Installation"
3
+ description: "Install Mercur and set up your marketplace project."
4
+ ---
5
+
6
+ ## Requirements
7
+
8
+ - [Node.js v20+](https://nodejs.org/en/download) (LTS version)
9
+ - [Bun v1.3+](https://bun.sh) (recommended package manager)
10
+ - [Git](https://git-scm.com/downloads)
11
+ - PostgreSQL v14+
12
+
13
+ <Tip>
14
+ The quickest way to get PostgreSQL running locally is with Docker:
15
+
16
+ ```bash
17
+ docker run -d --name mercur-postgres \
18
+ -e POSTGRES_PASSWORD=postgres \
19
+ -p 5432:5432 postgres:16
20
+ ```
21
+
22
+ Or on macOS with Homebrew:
23
+
24
+ ```bash
25
+ brew install postgresql@16 && brew services start postgresql@16
26
+ ```
27
+ </Tip>
28
+
29
+ ## Create a new project
30
+
31
+ ```bash
32
+ bun create mercur-app@rc
33
+ ```
34
+
35
+ The CLI will prompt for a project name and template, then handle everything automatically:
36
+ - downloads the template
37
+ - installs dependencies
38
+ - creates and migrates the database
39
+ - seeds initial data
40
+ - starts the development server and opens the admin setup page in your browser
41
+
42
+ ### Options
43
+
44
+ | Option | Description | Default |
45
+ |--------|-------------|---------|
46
+ | `--template <template>` | Template to use (`basic` or `plugin`) | prompted |
47
+ | `--db-connection-string <string>` | Full PostgreSQL connection string | — |
48
+ | `--db-host <host>` | PostgreSQL host | `localhost` |
49
+ | `--db-port <port>` | PostgreSQL port | `5432` |
50
+ | `--no-deps` | Skip dependency installation | — |
51
+ | `--skip-db` | Skip database setup | — |
52
+
53
+ ## Access your marketplace
54
+
55
+ Once the development server is running, your marketplace is available at:
56
+
57
+ | Panel | URL |
58
+ |-------|-----|
59
+ | API | `http://localhost:9000` |
60
+ | Admin Panel | `http://localhost:9000/dashboard` |
61
+ | Vendor Panel | `http://localhost:9000/seller` |
62
+
63
+ ### Create an admin account
64
+
65
+ The CLI automatically opens the admin invite page in your browser after setup. Follow the on-screen instructions to create your first admin account.
66
+
67
+ ### Create your first seller
68
+
69
+ The seed data does not include a seller account. To create one, open the Vendor Panel and register:
70
+
71
+ ```
72
+ http://localhost:9000/seller/register
73
+ ```
74
+
75
+ Fill in the registration form and complete the onboarding wizard. Once submitted, the seller will appear in the Admin Panel for approval.
76
+
77
+ ## Start the development server
78
+
79
+ After stopping the server, start it again from your project directory:
80
+
81
+ ```bash
82
+ cd <your-project-name>
83
+ bun dev
84
+ ```
85
+
86
+ ## Initialize an existing project
87
+
88
+ If you have an existing Medusa project, initialize Mercur in it:
89
+
90
+ ```bash
91
+ bunx @mercurjs/cli@rc init
92
+ ```
93
+
94
+ This creates a `blocks.json` configuration file in your project.
95
+
96
+ ## Add blocks
97
+
98
+ Install blocks from the registry:
99
+
100
+ ```bash
101
+ bunx @mercurjs/cli@rc add <block-name>
102
+ ```
103
+
104
+ Browse available blocks:
105
+
106
+ ```bash
107
+ bunx @mercurjs/cli@rc search
108
+ ```
109
+
110
+ ## Run database migrations
111
+
112
+ After adding blocks that include modules:
113
+
114
+ ```bash
115
+ bunx medusa db:generate <module1> <module2> ...
116
+ bunx medusa db:migrate
117
+ ```
@@ -0,0 +1,71 @@
1
+ ---
2
+ title: "Introduction"
3
+ description: "Mercur is an open-source marketplace platform built on MedusaJS with a block-based architecture."
4
+ ---
5
+
6
+ Mercur is an open-core **marketplace platform** built on top of the [Medusa Framework](https://medusajs.com). It follows a block-based architecture — install only the modules, workflows, API routes, and UI extensions you need directly into your project. No black-box dependencies, full code ownership.
7
+
8
+ ## What is Mercur
9
+
10
+ Medusa provides the underlying commerce engine — products, pricing, carts, orders, fulfillment, and events — while Mercur builds the marketplace domain layer on top of it.
11
+
12
+ On top of Medusa's core, Mercur introduces marketplace entities and workflows such as sellers, onboarding, product requests, commissions, reviews, return escalations, order splitting, vendor payouts, and dedicated Admin, Vendor, and Storefront APIs.
13
+
14
+ It comes with three optional interfaces:
15
+
16
+ - an **Admin Panel** for marketplace operators
17
+ - a **Vendor Portal** for seller teams
18
+ - a **Storefront** ready for marketplace scenarios
19
+
20
+ ## Why Mercur
21
+
22
+ ### Built on a modern stack
23
+
24
+ Mercur runs on a modern TypeScript backend powered by the Medusa framework, giving you a proven foundation for products, carts, orders, promotions, and payments. It integrates with technologies like Resend (notifications), Algolia (search), and Stripe Connect (payouts) — all replaceable when needed.
25
+
26
+ ### Block-based architecture
27
+
28
+ Unlike traditional plugins, Mercur uses a **block-based** approach. Blocks are copied directly into your project via the CLI, giving you full ownership and the ability to modify any piece of code without forking.
29
+
30
+ ### Full extensibility and ownership
31
+
32
+ Mercur is fully open-core and MIT-licensed. There are no transaction fees, no commercial lock-in, and no constraints on how your marketplace must behave. You own the entire codebase and can host it anywhere.
33
+
34
+ ## Building with AI
35
+
36
+ Mercur is designed so AI agents can build and extend your marketplace safely — not by generating code from scratch, but by working within structured guardrails.
37
+
38
+ ### How AI works with Mercur
39
+
40
+ Most AI coding tools generate loose snippets that you have to wire together yourself. Mercur gives AI something better to work with: a system with clear boundaries, typed contracts, and composable units.
41
+
42
+ Here's what that looks like in practice:
43
+
44
+ - **Adding features via CLI** — An AI agent can run `bunx @mercurjs/cli@rc add reviews` to install a complete review system — data models, API routes, workflows, and UI — in one command. No guessing at file structure or imports. The CLI handles wiring automatically.
45
+ - **Extending workflows without rebuilding them** — Need custom logic when an order is placed? AI can hook into the existing `complete-cart-with-split-orders` workflow and inject a step — without rewriting the entire cart flow. Medusa's workflow hooks make this safe and predictable.
46
+ - **Generating typed integrations** — AI reads the generated route types from `bunx @mercurjs/cli@rc codegen` and produces API calls that are correct by construction. No hallucinated endpoints, no wrong payloads — the types are the source of truth.
47
+ - **Building UI pages** — AI can scaffold an admin or vendor page by creating a file in `src/routes/`. The dashboard SDK picks it up automatically through file-based routing. No manual route registration, no config files to update.
48
+ - **Modifying blocks it can diff** — AI can compare local code against the registry with `bunx @mercurjs/cli@rc diff`, understand what changed, and make targeted modifications instead of blind overwrites.
49
+
50
+ ### Connect your AI tools
51
+
52
+ To start building with AI, connect your environment to Mercur's knowledge base:
53
+
54
+ - **[Building with AI](/rc/resources/ai/overview)** — How Mercur bundles version-matched docs into your project so agents build from accurate APIs, not stale training data
55
+ - **[LLMs](/rc/resources/ai/llms)** — Feed the full Mercur documentation to any LLM via `llms.txt`
56
+ - **[MCP Server](/rc/resources/ai/mcp)** — Let your AI tool search Mercur docs in real time (Cursor, VS Code, Claude, Claude Code)
57
+
58
+ ### Why this matters
59
+
60
+ Traditional commerce platforms give AI no structure to reason about. The result is generated code that looks plausible but breaks in production — wrong API shapes, missing relationships, incompatible data models.
61
+
62
+ Mercur solves this with:
63
+
64
+ - **Typed API Client** — API specifications shared between server and client. AI reads real types, not documentation that may be outdated.
65
+ - **Block Registry** — Features are discrete, well-defined units. AI can inspect what a block contains before installing it and verify the result after.
66
+ - **Monorepo** — Backend, admin, vendor, and shared packages live in one workspace. AI has full context without jumping between repositories.
67
+ - **Core Workflows** — Cart, orders, pricing, and vendor logic are exposed as structured steps. AI extends them through hooks rather than patching source code.
68
+ - **Dashboard SDK** — File-based routing and virtual modules mean AI adds pages and components by creating files in the right place. The SDK handles registration.
69
+ - **Marketplace Payments** — Payout providers follow a pluggable interface. AI can implement a new provider by conforming to the contract, not by reverse-engineering Stripe integration code.
70
+
71
+ The result: AI agents can compose real marketplace systems — not just write code, but add capabilities, extend business logic, and evolve your architecture with guardrails that prevent mistakes.
@@ -0,0 +1,78 @@
1
+ ---
2
+ title: "Offers"
3
+ description: "An offer is a seller's sellable listing against a master product — their own SKU, price, inventory, and shipping."
4
+ ---
5
+
6
+ An **offer** is how a seller actually sells something. While [products](/rc/learn/products) form a shared master catalog, an offer binds one seller to one product variant with the seller's own commercial terms: SKU, price, stock, and shipping profile. Many sellers can hold offers against the same variant, each competing on price and availability.
7
+
8
+ ## Data model
9
+
10
+ | Field | Description |
11
+ |-------|-------------|
12
+ | `id` | Prefixed with `offer_` |
13
+ | `seller_id` | The seller who owns the listing |
14
+ | `product_id` / `variant_id` | The master catalog entry the offer sells |
15
+ | `sku` | The seller's own SKU — unique per seller |
16
+ | `ean` / `upc` | Optional barcodes, searchable |
17
+ | `shipping_profile_id` | The seller's shipping profile used to fulfill this offer |
18
+ | `created_by` | The member who created the offer |
19
+ | `metadata` | Free-form JSON |
20
+
21
+ The `(seller_id, sku)` pair is unique: a seller cannot list the same SKU twice.
22
+
23
+ ## Relationships
24
+
25
+ Offers sit at the center of the seller's commercial graph. Module links connect each offer to:
26
+
27
+ - **Seller** — the listing owner
28
+ - **Product and variant** — the master catalog entry
29
+ - **Price** — offer-scoped pricing (see below)
30
+ - **Inventory item** — offer-scoped stock (see below)
31
+ - **Shipping profile** — how the offer ships
32
+ - **Cart and order line items** — which offer a purchased line came from
33
+
34
+ ### Offer-scoped pricing
35
+
36
+ Offers share the variant's price set, scoped by an offer rule — each offer carries its own prices without duplicating the variant. The storefront computes a `calculated_price` per offer, so two sellers listing the same variant can show different prices side by side.
37
+
38
+ ### Offer-scoped inventory
39
+
40
+ Inventory is linked to the **offer, not the variant**. Each seller manages stock for their own listing independently; a variant has no marketplace-wide stock figure of its own.
41
+
42
+ <Warning>
43
+ When working with offer orders, read inventory through the offer link. The variant's own `inventory_items` relation is empty for offer-based listings.
44
+ </Warning>
45
+
46
+ ## Offers at checkout
47
+
48
+ When a customer buys, the cart line item links to the specific offer that was purchased. The link is preserved onto the order line item, so fulfillment, commission calculation, and payouts all resolve to the right seller — even when several sellers list the same variant.
49
+
50
+ ## Discovery
51
+
52
+ The Store API exposes offers directly:
53
+
54
+ ```bash
55
+ curl "http://localhost:9000/store/offers?product_id=prod_123" \
56
+ -H "x-publishable-api-key: <key>"
57
+ ```
58
+
59
+ This powers "buy box"-style storefronts: fetch a product from the shared catalog, then list every seller's offer against it with per-offer calculated prices.
60
+
61
+ ## Where offers appear
62
+
63
+ | Surface | Capability |
64
+ |---------|-----------|
65
+ | Vendor Portal | Full lifecycle — create offers, edit price and stock, manage variants and inventory |
66
+ | Admin Panel | Oversight — list and inspect all offers with their store, pricing, inventory, and the associated master product |
67
+ | Store API | Browse offers per product, with per-offer calculated prices |
68
+
69
+ ## Next steps
70
+
71
+ <CardGroup cols={2}>
72
+ <Card title="Products" href="/rc/learn/products">
73
+ The shared master catalog offers are built on.
74
+ </Card>
75
+ <Card title="Order Groups" href="/rc/learn/order-groups">
76
+ How multi-seller purchases split into per-seller orders.
77
+ </Card>
78
+ </CardGroup>
@@ -0,0 +1,114 @@
1
+ ---
2
+ title: "Order Groups"
3
+ description: "How multi-seller checkout creates order groups — the container that ties a single cart to multiple seller orders."
4
+ ---
5
+
6
+ An order group is a container created during checkout when a customer buys from multiple sellers. It groups the individual per-seller orders that originate from a single cart, giving customers and admins a unified view of what was purchased.
7
+
8
+ ## Data model
9
+
10
+ | Field | Type | Description |
11
+ |-------|------|-------------|
12
+ | `id` | `text` | Unique identifier (prefix `og_`) |
13
+ | `display_id` | `serial` | Auto-incrementing human-readable ID |
14
+ | `customer_id` | `text` | The customer who placed the order (nullable) |
15
+ | `cart_id` | `text` | The cart this order group originated from |
16
+ | `seller_count` | `number` | Number of distinct sellers in the group (computed) |
17
+ | `total` | `bigNumber` | Sum of all order totals in the group (computed) |
18
+
19
+ <Info>
20
+ `seller_count` and `total` are **computed fields** — they are calculated from linked orders at query time, not stored as columns. `seller_count` is the count of distinct sellers across all orders in the group, and `total` is the sum of each order's `current_order_total` from the order summary.
21
+ </Info>
22
+
23
+ ## Relationships
24
+
25
+ Order groups connect to other entities through two links:
26
+
27
+ ### Cart (read-only)
28
+
29
+ Links the order group back to its originating cart via the `cart_id` field. This is a read-only link — carts are immutable after checkout.
30
+
31
+ ```
32
+ order_group.cart_id → cart.id
33
+ ```
34
+
35
+ ### Orders (one-to-many)
36
+
37
+ Links the order group to multiple orders through a join table `order_group_order`. Each order in the group belongs to a different seller.
38
+
39
+ ```
40
+ order_group ←→ order (via order_group_order)
41
+ ```
42
+
43
+ ## How order groups are created
44
+
45
+ Order groups are created automatically during checkout by the `completeCartWithSplitOrdersWorkflow`. This is what happens when a customer completes a cart containing products from multiple sellers:
46
+
47
+ 1. **Lock** — The workflow acquires a lock on the cart to prevent double-processing
48
+ 2. **Group by seller** — Cart items are grouped by seller (via the product-seller link)
49
+ 3. **Create orders** — A separate Medusa order is created for each seller, containing only that seller's items and shipping
50
+ 4. **Create order group** — An order group is created with the customer and cart references
51
+ 5. **Link everything** — The workflow creates links between:
52
+ - Each order and the order group
53
+ - Each order and its seller
54
+ - Each order and the cart's payment collection
55
+ - Each seller and the customer (if new relationship)
56
+ 6. **Finalize** — Inventory is reserved, payment is authorized, and the `order_group.created` event is emitted
57
+
58
+ <Info>
59
+ Payment collections are linked at the **individual order level**, not on the order group. This is a deliberate design decision — each per-seller order gets its own link to the payment collection, which enables per-order capture and refund flows.
60
+ </Info>
61
+
62
+ ## Events
63
+
64
+ | Event | Payload | When |
65
+ |-------|---------|------|
66
+ | `order_group.created` | `{ id: string }` | After checkout creates a new order group |
67
+
68
+ ## API endpoints
69
+
70
+ ### List order groups (Admin)
71
+
72
+ ```bash
73
+ curl http://localhost:9000/admin/order-groups \
74
+ -H "Authorization: Bearer <admin-token>"
75
+ ```
76
+
77
+ Supports filtering by `customer_id`, `seller_id`, `status`, `sales_channel_id`, and `created_at`. Paginated with `offset` and `limit` (default 50).
78
+
79
+ ### Get order group detail (Admin)
80
+
81
+ ```bash
82
+ curl http://localhost:9000/admin/order-groups/<order-group-id> \
83
+ -H "Authorization: Bearer <admin-token>"
84
+ ```
85
+
86
+ Returns the order group with aggregated payment and fulfillment statuses across all orders.
87
+
88
+ ### List order groups (Store)
89
+
90
+ ```bash
91
+ curl http://localhost:9000/store/order-groups \
92
+ -H "Authorization: Bearer <customer-token>"
93
+ ```
94
+
95
+ Returns only order groups belonging to the authenticated customer. Includes nested order data with items, variants, products, and seller information.
96
+
97
+ ### Get order group detail (Store)
98
+
99
+ ```bash
100
+ curl http://localhost:9000/store/order-groups/<order-group-id> \
101
+ -H "Authorization: Bearer <customer-token>"
102
+ ```
103
+
104
+ Returns a single order group. Throws `404` if the order group doesn't belong to the authenticated customer.
105
+
106
+ ## Workflows
107
+
108
+ | Workflow | Purpose |
109
+ |----------|---------|
110
+ | `getOrderGroupsListWorkflow` | Retrieves a paginated list of order groups with aggregated payment and fulfillment statuses for each |
111
+ | `getOrderGroupDetailWorkflow` | Retrieves a single order group with full order details and aggregated statuses |
112
+ | `createOrderGroupStep` | Internal step used by `completeCartWithSplitOrdersWorkflow` — not called directly |
113
+
114
+ The list and detail workflows automatically inject order-related fields (items, payment collections, fulfillments) and compute an overall `payment_status` and `fulfillment_status` for each order group by aggregating across all linked orders.