@mercurjs/docs 2.2.1 → 2.3.0-canary.1
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.
- package/content/home.mdx +107 -0
- package/content/learn/architecture.mdx +168 -83
- package/content/learn/introduction.mdx +161 -56
- package/content/learn/migration-to-2-0.mdx +187 -0
- package/content/learn/why-mercur.mdx +91 -0
- package/content/platform/attribute/concepts/attribute-types.mdx +59 -0
- package/content/platform/attribute/concepts/global-vs-inline.mdx +50 -0
- package/content/platform/attribute/concepts/variant-axes.mdx +61 -0
- package/content/platform/attribute/guides/attach-attributes-to-a-product.mdx +69 -0
- package/content/platform/attribute/guides/create-a-variant-axis.mdx +83 -0
- package/content/platform/attribute/guides/create-an-attribute.mdx +81 -0
- package/content/platform/attribute/overview.mdx +87 -0
- package/content/platform/attribute/reference/data-models.mdx +56 -0
- package/content/platform/attribute/reference/events.mdx +41 -0
- package/content/platform/attribute/reference/links.mdx +45 -0
- package/content/platform/attribute/reference/service.mdx +49 -0
- package/content/platform/attribute/reference/workflows.mdx +45 -0
- package/content/platform/catalog/concepts/master-products.mdx +54 -0
- package/content/platform/catalog/concepts/product-seller-allowlist.mdx +48 -0
- package/content/platform/catalog/concepts/status-lifecycle.mdx +58 -0
- package/content/platform/catalog/concepts/variants-categories-collections.mdx +49 -0
- package/content/platform/catalog/guides/allowlist-stores.mdx +59 -0
- package/content/platform/catalog/guides/create-a-master-product.mdx +70 -0
- package/content/platform/catalog/guides/publish-or-reject-a-product.mdx +79 -0
- package/content/platform/catalog/overview.mdx +90 -0
- package/content/platform/catalog/reference/data-models.mdx +66 -0
- package/content/platform/catalog/reference/events.mdx +41 -0
- package/content/platform/catalog/reference/links.mdx +44 -0
- package/content/platform/catalog/reference/service.mdx +52 -0
- package/content/platform/catalog/reference/workflows.mdx +40 -0
- package/content/platform/commission/concepts/order-commission-lines.mdx +65 -0
- package/content/platform/commission/concepts/rule-matching.mdx +86 -0
- package/content/platform/commission/concepts/rules-and-rates.mdx +84 -0
- package/content/platform/commission/guides/batch-update-rules.mdx +58 -0
- package/content/platform/commission/guides/create-a-rate.mdx +72 -0
- package/content/platform/commission/guides/refresh-order-commission-lines.mdx +55 -0
- package/content/platform/commission/overview.mdx +86 -0
- package/content/platform/commission/reference/data-models.mdx +75 -0
- package/content/platform/commission/reference/events.mdx +58 -0
- package/content/platform/commission/reference/links.mdx +45 -0
- package/content/platform/commission/reference/service.mdx +51 -0
- package/content/platform/commission/reference/workflows.mdx +40 -0
- package/content/platform/offer/concepts/pricing-and-inventory.mdx +72 -0
- package/content/platform/offer/concepts/shipping.mdx +48 -0
- package/content/platform/offer/concepts/what-is-an-offer.mdx +65 -0
- package/content/platform/offer/guides/bulk-create-offers.mdx +84 -0
- package/content/platform/offer/guides/create-an-offer.mdx +83 -0
- package/content/platform/offer/guides/manage-offer-inventory.mdx +53 -0
- package/content/platform/offer/overview.mdx +84 -0
- package/content/platform/offer/reference/data-models.mdx +56 -0
- package/content/platform/offer/reference/events.mdx +39 -0
- package/content/platform/offer/reference/links.mdx +60 -0
- package/content/platform/offer/reference/service.mdx +53 -0
- package/content/platform/offer/reference/workflows.mdx +38 -0
- package/content/platform/order-group/concepts/computed-totals.mdx +59 -0
- package/content/platform/order-group/concepts/order-splitting.mdx +61 -0
- package/content/platform/order-group/concepts/the-order-group.mdx +64 -0
- package/content/platform/order-group/guides/list-order-groups.mdx +67 -0
- package/content/platform/order-group/guides/retrieve-an-order-group.mdx +63 -0
- package/content/platform/order-group/guides/split-a-cart.mdx +58 -0
- package/content/platform/order-group/overview.mdx +83 -0
- package/content/platform/order-group/reference/data-models.mdx +40 -0
- package/content/platform/order-group/reference/events.mdx +37 -0
- package/content/platform/order-group/reference/links.mdx +45 -0
- package/content/platform/order-group/reference/service.mdx +50 -0
- package/content/platform/order-group/reference/workflows.mdx +39 -0
- package/content/platform/payout/concepts/account-lifecycle.mdx +75 -0
- package/content/platform/payout/concepts/accounts-and-onboarding.mdx +70 -0
- package/content/platform/payout/concepts/payout-pipeline.mdx +99 -0
- package/content/platform/payout/guides/create-a-payout-account.mdx +59 -0
- package/content/platform/payout/guides/process-a-provider-webhook.mdx +74 -0
- package/content/platform/payout/guides/start-provider-onboarding.mdx +50 -0
- package/content/platform/payout/overview.mdx +86 -0
- package/content/platform/payout/reference/data-models.mdx +61 -0
- package/content/platform/payout/reference/events.mdx +48 -0
- package/content/platform/payout/reference/links.mdx +36 -0
- package/content/platform/payout/reference/service.mdx +53 -0
- package/content/platform/payout/reference/workflows.mdx +32 -0
- package/content/platform/product-edit/concepts/change-actions.mdx +66 -0
- package/content/platform/product-edit/concepts/change-pipeline.mdx +69 -0
- package/content/platform/product-edit/concepts/status-and-auto-confirm.mdx +66 -0
- package/content/platform/product-edit/guides/confirm-or-decline-a-change.mdx +76 -0
- package/content/platform/product-edit/guides/edit-a-product.mdx +74 -0
- package/content/platform/product-edit/guides/request-a-revision.mdx +54 -0
- package/content/platform/product-edit/overview.mdx +85 -0
- package/content/platform/product-edit/reference/data-models.mdx +65 -0
- package/content/platform/product-edit/reference/events.mdx +47 -0
- package/content/platform/product-edit/reference/links.mdx +39 -0
- package/content/platform/product-edit/reference/service.mdx +43 -0
- package/content/platform/product-edit/reference/workflows.mdx +49 -0
- package/content/platform/review/concepts/product-vs-seller-reviews.mdx +63 -0
- package/content/platform/review/concepts/ratings-and-moderation.mdx +64 -0
- package/content/platform/review/concepts/the-review-model.mdx +56 -0
- package/content/platform/review/guides/compute-aggregate-ratings.mdx +57 -0
- package/content/platform/review/guides/create-a-review.mdx +55 -0
- package/content/platform/review/guides/moderate-a-review.mdx +58 -0
- package/content/platform/review/guides/respond-to-a-review.mdx +61 -0
- package/content/platform/review/overview.mdx +87 -0
- package/content/platform/review/reference/data-models.mdx +36 -0
- package/content/platform/review/reference/events.mdx +61 -0
- package/content/platform/review/reference/links.mdx +43 -0
- package/content/platform/review/reference/service.mdx +54 -0
- package/content/platform/review/reference/workflows.mdx +31 -0
- package/content/platform/store/concepts/lifecycle.mdx +62 -0
- package/content/platform/store/concepts/store-entity.mdx +53 -0
- package/content/platform/store/concepts/team.mdx +50 -0
- package/content/platform/store/guides/create-a-store.mdx +55 -0
- package/content/platform/store/guides/manage-the-team.mdx +55 -0
- package/content/platform/store/guides/moderate-a-store.mdx +59 -0
- package/content/platform/store/overview.mdx +86 -0
- package/content/platform/store/reference/data-models.mdx +89 -0
- package/content/platform/store/reference/events.mdx +43 -0
- package/content/platform/store/reference/links.mdx +71 -0
- package/content/platform/store/reference/service.mdx +51 -0
- package/content/platform/store/reference/workflows.mdx +35 -0
- package/content/references/api/admin/commission-rates/create-commission-rate.mdx +1 -1
- package/content/references/api/admin/commission-rates/list-commission-rates.mdx +2 -2
- package/content/references/api/admin/commission-rates/update-commission-rate.mdx +1 -1
- package/content/references/api/admin/offers/batch-create-offers.mdx +3 -3
- package/content/references/api/admin/order-groups/list-order-groups.mdx +1 -1
- package/content/references/api/admin/product-attributes/create-attribute-value.mdx +2 -2
- package/content/references/api/admin/product-attributes/create-product-attribute.mdx +1 -1
- package/content/references/api/admin/product-attributes/update-product-attribute.mdx +1 -1
- package/content/references/api/admin/product-changes/confirm-product-change.mdx +1 -1
- package/content/references/api/admin/products/batch-product-attributes.mdx +1 -1
- package/content/references/api/admin/products/create-product.mdx +1 -1
- package/content/references/api/admin/products/preview-product.mdx +1 -1
- package/content/references/api/admin.mdx +4 -5
- package/content/references/api/conventions.mdx +9 -7
- package/content/references/api/store/carts/add-line-item.mdx +1 -1
- package/content/references/api/store/offers/list-offers.mdx +1 -1
- package/content/references/api/store/order-groups/list-order-groups.mdx +1 -1
- package/content/references/api/store.mdx +4 -13
- package/content/references/api/vendor/members/accept-member-invite.mdx +1 -1
- package/content/references/api/vendor/offers/batch-create-offers.mdx +4 -0
- package/content/references/api/vendor/offers/batch-offer-inventory-items.mdx +2 -0
- package/content/references/api/vendor/offers/create-offer.mdx +13 -1
- package/content/references/api/vendor/offers/list-offers.mdx +4 -0
- package/content/references/api/vendor/offers/retrieve-offer.mdx +4 -0
- package/content/references/api/vendor/offers/update-offer.mdx +12 -0
- package/content/references/api/vendor/payout-accounts/create-onboarding.mdx +1 -1
- package/content/references/api/vendor/products/batch-product-attributes.mdx +1 -1
- package/content/references/api/vendor/products/create-product-variant.mdx +1 -1
- package/content/references/api/vendor/products/create-product.mdx +1 -1
- package/content/references/api/vendor/products/delete-product.mdx +1 -1
- package/content/references/api/vendor/products/update-product.mdx +1 -1
- package/content/references/api/vendor/sellers/create-seller.mdx +2 -2
- package/content/references/api/vendor/sellers/list-sellers.mdx +1 -1
- package/content/references/api/vendor.mdx +6 -5
- package/content/references/configuration.mdx +16 -33
- package/content/references/overview.mdx +34 -52
- package/content/references/panel-extensions/create-page.mdx +194 -0
- package/content/references/panel-extensions/custom-fields.mdx +256 -0
- package/content/references/panel-extensions/overview.mdx +102 -0
- package/content/references/panel-extensions/widgets.mdx +212 -0
- package/content/resources/ai/mcp.mdx +2 -2
- package/content/resources/ai/overview.mdx +21 -16
- package/content/resources/ai/skills.mdx +67 -0
- package/content/resources/best-practices/api-routes.mdx +55 -43
- package/content/resources/best-practices/custom-fields.mdx +116 -92
- package/content/resources/best-practices/frontend.mdx +62 -50
- package/content/resources/best-practices/module-links.mdx +48 -34
- package/content/resources/best-practices/modules.mdx +53 -27
- package/content/resources/best-practices/overview.mdx +45 -17
- package/content/resources/best-practices/subscribers-and-jobs.mdx +37 -24
- package/content/resources/best-practices/types.mdx +38 -23
- package/content/resources/best-practices/workflows.mdx +33 -21
- package/content/resources/customization/custom-fields.mdx +15 -15
- package/content/resources/customization/extend-a-workflow.mdx +7 -4
- package/content/resources/customization/extending-panels.mdx +55 -52
- package/content/resources/deployment/medusa-cloud.mdx +21 -20
- package/content/resources/deployment/self-host.mdx +123 -0
- package/content/resources/integrations/overview.mdx +38 -0
- package/content/resources/integrations/stripe-connect.mdx +39 -38
- package/content/resources/tutorials/add-a-block.mdx +25 -18
- package/content/resources/tutorials/add-a-widget.mdx +32 -23
- package/content/resources/tutorials/add-order-detail-button.mdx +33 -20
- package/content/resources/tutorials/attributes-and-variant-axes.mdx +28 -27
- package/content/resources/tutorials/build-a-block.mdx +26 -15
- package/content/resources/tutorials/custom-api-route.mdx +32 -20
- package/content/resources/tutorials/custom-panel-page.mdx +21 -12
- package/content/resources/tutorials/customize-navigation.mdx +30 -23
- package/content/resources/tutorials/extend-forms-and-tables.mdx +36 -28
- package/content/resources/tutorials/extend-onboarding.mdx +38 -35
- package/content/resources/tutorials/master-products-and-offers.mdx +28 -23
- package/content/telemetry.mdx +3 -3
- package/content/user-guide/admin/attributes/how-tos/create-an-attribute.mdx +64 -0
- package/content/user-guide/admin/attributes/how-tos/manage-possible-values.mdx +40 -0
- package/content/user-guide/admin/attributes/overview.mdx +22 -0
- package/content/user-guide/admin/commissions/how-tos/create-a-commission-rule.mdx +63 -0
- package/content/user-guide/admin/commissions/how-tos/edit-the-global-commission.mdx +48 -0
- package/content/user-guide/admin/commissions/how-tos/manage-a-commission-rule.mdx +45 -0
- package/content/user-guide/admin/commissions/overview.mdx +25 -0
- package/content/user-guide/admin/overview.mdx +20 -12
- package/content/user-guide/admin/product-requests/how-tos/review-a-new-product.mdx +58 -0
- package/content/user-guide/admin/product-requests/how-tos/review-a-product-edit.mdx +48 -0
- package/content/user-guide/admin/product-requests/overview.mdx +25 -0
- package/content/user-guide/vendor/offers/how-tos/create-an-offer.mdx +59 -0
- package/content/user-guide/vendor/offers/how-tos/update-prices-and-stock.mdx +40 -0
- package/content/user-guide/vendor/offers/overview.mdx +22 -0
- package/content/user-guide/vendor/onboarding.mdx +79 -0
- package/content/user-guide/vendor/orders/how-tos/fulfill-an-order.mdx +49 -0
- package/content/user-guide/vendor/orders/how-tos/mark-an-order-as-delivered.mdx +33 -0
- package/content/user-guide/vendor/orders/how-tos/process-a-return.mdx +42 -0
- package/content/user-guide/vendor/orders/how-tos/refund-an-order.mdx +38 -0
- package/content/user-guide/vendor/orders/how-tos/ship-an-order.mdx +40 -0
- package/content/user-guide/vendor/orders/overview.mdx +31 -0
- package/content/user-guide/vendor/overview.mdx +23 -12
- package/content/user-guide/vendor/products/how-tos/edit-a-product.mdx +44 -0
- package/content/user-guide/vendor/products/how-tos/submit-a-product.mdx +63 -0
- package/content/user-guide/vendor/products/overview.mdx +22 -0
- package/llms.txt +176 -142
- package/package.json +1 -1
- package/content/learn/concepts.mdx +0 -84
- package/content/learn/installation.mdx +0 -117
- package/content/learn/mirakl-alternative.mdx +0 -86
- package/content/migration/from-1-x-to-2-0.mdx +0 -152
- package/content/migration/from-2-0-to-2-1.mdx +0 -105
- package/content/migration/overview.mdx +0 -58
- package/content/references/api/store/search/search.mdx +0 -136
- package/content/references/modules/commission.mdx +0 -106
- package/content/references/modules/custom-fields.mdx +0 -45
- package/content/references/modules/media.mdx +0 -55
- package/content/references/modules/offer.mdx +0 -64
- package/content/references/modules/payout.mdx +0 -121
- package/content/references/modules/product-attribute.mdx +0 -111
- package/content/references/modules/product-edit.mdx +0 -80
- package/content/references/modules/search.mdx +0 -112
- package/content/references/modules/seller.mdx +0 -175
- package/content/references/panel-extension-api.mdx +0 -337
- package/content/references/workflows/cart/add-seller-shipping-method-to-cart.mdx +0 -48
- package/content/references/workflows/cart/complete-cart-with-split-orders.mdx +0 -36
- package/content/references/workflows/cart/list-seller-shipping-options-for-cart.mdx +0 -39
- package/content/references/workflows/cart/update-cart-seller-promotions.mdx +0 -42
- package/content/references/workflows/commission/batch-commission-rules.mdx +0 -49
- package/content/references/workflows/commission/create-commission-rates.mdx +0 -41
- package/content/references/workflows/commission/delete-commission-rates.mdx +0 -34
- package/content/references/workflows/commission/refresh-order-commission-lines.mdx +0 -30
- package/content/references/workflows/commission/update-commission-rates.mdx +0 -35
- package/content/references/workflows/media/set-category-images.mdx +0 -41
- package/content/references/workflows/media/set-collection-images.mdx +0 -41
- package/content/references/workflows/member/accept-member-invite.mdx +0 -33
- package/content/references/workflows/member/add-seller-member.mdx +0 -30
- package/content/references/workflows/member/create-member-invites.mdx +0 -34
- package/content/references/workflows/member/delete-member-invite.mdx +0 -24
- package/content/references/workflows/member/remove-seller-member.mdx +0 -28
- package/content/references/workflows/member/resend-member-invite.mdx +0 -28
- package/content/references/workflows/member/update-member-role.mdx +0 -28
- package/content/references/workflows/member/update-member.mdx +0 -35
- package/content/references/workflows/offer/batch-offer-inventory-items.mdx +0 -62
- package/content/references/workflows/offer/create-offers.mdx +0 -65
- package/content/references/workflows/offer/delete-offers.mdx +0 -35
- package/content/references/workflows/offer/update-offers.mdx +0 -53
- package/content/references/workflows/order/cancel-order-fulfillment.mdx +0 -34
- package/content/references/workflows/order/confirm-claim-request.mdx +0 -25
- package/content/references/workflows/order/confirm-exchange-request.mdx +0 -25
- package/content/references/workflows/order/confirm-order-edit-request.mdx +0 -25
- package/content/references/workflows/order/confirm-return-receive.mdx +0 -25
- package/content/references/workflows/order/create-order-fulfillment.mdx +0 -45
- package/content/references/workflows/order-group/get-order-group-detail.mdx +0 -29
- package/content/references/workflows/order-group/get-order-groups-list.mdx +0 -38
- package/content/references/workflows/overview.mdx +0 -72
- package/content/references/workflows/payout/create-onboarding.mdx +0 -36
- package/content/references/workflows/payout/create-payout-account.mdx +0 -33
- package/content/references/workflows/payout/create-payout.mdx +0 -30
- package/content/references/workflows/payout/process-payout-for-webhook.mdx +0 -34
- package/content/references/workflows/product/confirm-products.mdx +0 -48
- package/content/references/workflows/product/create-products.mdx +0 -63
- package/content/references/workflows/product/link-sellers-to-product-category.mdx +0 -40
- package/content/references/workflows/product/link-sellers-to-product.mdx +0 -40
- package/content/references/workflows/product/reject-product.mdx +0 -48
- package/content/references/workflows/product/request-product-change.mdx +0 -48
- package/content/references/workflows/product-attribute/add-product-attributes-to-product.mdx +0 -49
- package/content/references/workflows/product-attribute/create-and-link-product-attributes-to-product.mdx +0 -46
- package/content/references/workflows/product-attribute/create-product-attribute-values.mdx +0 -43
- package/content/references/workflows/product-attribute/create-product-attributes.mdx +0 -56
- package/content/references/workflows/product-attribute/delete-product-attribute-values.mdx +0 -30
- package/content/references/workflows/product-attribute/delete-product-attributes.mdx +0 -30
- package/content/references/workflows/product-attribute/remove-product-attributes-from-product.mdx +0 -29
- package/content/references/workflows/product-attribute/update-product-attribute-values.mdx +0 -44
- package/content/references/workflows/product-attribute/update-product-attributes-on-product.mdx +0 -41
- package/content/references/workflows/product-attribute/update-product-attributes.mdx +0 -48
- package/content/references/workflows/product-attribute/upsert-product-attribute-values.mdx +0 -43
- package/content/references/workflows/product-edit/auto-confirm-product-change.mdx +0 -39
- package/content/references/workflows/product-edit/cancel-product-change.mdx +0 -49
- package/content/references/workflows/product-edit/confirm-product-change.mdx +0 -57
- package/content/references/workflows/product-edit/create-product-change.mdx +0 -72
- package/content/references/workflows/product-edit/reject-product-change.mdx +0 -54
- package/content/references/workflows/product-edit/stage-product-change.mdx +0 -75
- package/content/references/workflows/seller/approve-seller.mdx +0 -36
- package/content/references/workflows/seller/create-seller-account.mdx +0 -59
- package/content/references/workflows/seller/create-seller-defaults.mdx +0 -22
- package/content/references/workflows/seller/create-sellers.mdx +0 -65
- package/content/references/workflows/seller/delete-seller-professional-details.mdx +0 -37
- package/content/references/workflows/seller/delete-sellers.mdx +0 -24
- package/content/references/workflows/seller/invite-seller.mdx +0 -28
- package/content/references/workflows/seller/suspend-seller.mdx +0 -37
- package/content/references/workflows/seller/terminate-seller.mdx +0 -37
- package/content/references/workflows/seller/unsuspend-seller.mdx +0 -36
- package/content/references/workflows/seller/unterminate-seller.mdx +0 -36
- package/content/references/workflows/seller/update-seller-address.mdx +0 -55
- package/content/references/workflows/seller/update-seller-payment-details.mdx +0 -52
- package/content/references/workflows/seller/update-seller-professional-details.mdx +0 -48
- package/content/references/workflows/seller/update-sellers.mdx +0 -57
- package/content/resources/ai/llms.mdx +0 -74
- package/content/resources/integrations/notifications.mdx +0 -39
- package/content/resources/integrations/search.mdx +0 -122
- package/content/resources/tutorials/configure-commissions.mdx +0 -127
- package/content/resources/tutorials/first-marketplace.mdx +0 -45
- package/content/resources/tutorials/handle-product-requests.mdx +0 -80
- package/content/resources/tutorials/import-export-products.mdx +0 -96
- package/content/resources/tutorials/seller-payouts-stripe.mdx +0 -89
- package/content/resources/tutorials/store-setup-checklist.mdx +0 -214
- package/content/tools/api-client.mdx +0 -155
- package/content/tools/cli.mdx +0 -196
- package/content/tools/dashboard-sdk.mdx +0 -35
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Links to other modules"
|
|
3
|
+
sidebarTitle: "Links"
|
|
4
|
+
description: "How the Commission domain connects to the catalog, sellers, and orders."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Most Mercur modules connect to each other through **module links** (`defineLink`)
|
|
8
|
+
resolved with `query.graph`. The Commission module is deliberately different: it
|
|
9
|
+
defines **no** module links. Instead it connects to the rest of the marketplace
|
|
10
|
+
through **soft references**. These are plain id fields resolved at calculation
|
|
11
|
+
time. This keeps commission configuration independent of the catalog and order
|
|
12
|
+
modules it scopes against.
|
|
13
|
+
|
|
14
|
+
## Rules → catalog & sellers
|
|
15
|
+
|
|
16
|
+
A `CommissionRule` points at a record in another domain through its
|
|
17
|
+
`reference` / `reference_id` pair, resolved against the order line's product when
|
|
18
|
+
commission is calculated:
|
|
19
|
+
|
|
20
|
+
| `reference` | Points at | Resolved from |
|
|
21
|
+
| --- | --- | --- |
|
|
22
|
+
| `product` | A master product | `item.product.id` |
|
|
23
|
+
| `product_type` | A product type | `item.product.type_id` |
|
|
24
|
+
| `product_collection` | A collection | `item.product.collection_id` |
|
|
25
|
+
| `product_category` | A category | `item.product.categories[].id` |
|
|
26
|
+
| `seller` | A store | `item.offer.seller_id` |
|
|
27
|
+
|
|
28
|
+
<Note>
|
|
29
|
+
Products are the shared master catalog, not seller-owned. The `seller`
|
|
30
|
+
dimension resolves through the **offer** on the order line, which carries the
|
|
31
|
+
selling store.
|
|
32
|
+
</Note>
|
|
33
|
+
|
|
34
|
+
## Lines → orders
|
|
35
|
+
|
|
36
|
+
A `CommissionLine` records which order line it commissions through its
|
|
37
|
+
`item_id` (an order line item) or `shipping_method_id` (a shipping method).
|
|
38
|
+
These are stored as plain ids, so the payout pipeline reads an order's lines by
|
|
39
|
+
querying the commission module directly rather than traversing a link.
|
|
40
|
+
|
|
41
|
+
<Tip>
|
|
42
|
+
Because these are soft references, deleting a product, category, or order does
|
|
43
|
+
not cascade to commission records. Rules and lines simply stop matching or are
|
|
44
|
+
refreshed on the next order change.
|
|
45
|
+
</Tip>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Service reference"
|
|
3
|
+
sidebarTitle: "Service"
|
|
4
|
+
description: "The Commission module service and its methods for working with records directly."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
The Commission module exposes a service you can resolve from the Medusa
|
|
8
|
+
container to read and write records directly, without going through a workflow.
|
|
9
|
+
Use it inside custom services, subscribers, or scheduled jobs.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { MercurModules } from "@mercurjs/types"
|
|
13
|
+
|
|
14
|
+
const commissionModuleService = container.resolve(MercurModules.COMMISSION)
|
|
15
|
+
|
|
16
|
+
const [rates, count] = await commissionModuleService.listAndCountCommissionRates(
|
|
17
|
+
{ is_enabled: true }
|
|
18
|
+
)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Generated methods
|
|
22
|
+
|
|
23
|
+
Each data model gets a standard set of auto-generated methods. For
|
|
24
|
+
`CommissionRate`:
|
|
25
|
+
|
|
26
|
+
| Method | Description |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| `createCommissionRates(data)` | Create one or more rates (auto-generates `code`) |
|
|
29
|
+
| `retrieveCommissionRate(id, config?)` | Retrieve a rate by id |
|
|
30
|
+
| `listCommissionRates(filters?, config?)` | List rates matching filters |
|
|
31
|
+
| `listAndCountCommissionRates(filters?, config?)` | List rates with a total count |
|
|
32
|
+
| `updateCommissionRates(data)` | Update one or more rates |
|
|
33
|
+
| `deleteCommissionRates(ids)` | Delete one or more rates |
|
|
34
|
+
|
|
35
|
+
The same set exists for every model in the module: `CommissionRule`,
|
|
36
|
+
`CommissionRateValue`, and `CommissionLine` (e.g. `createCommissionRules`,
|
|
37
|
+
`listCommissionRateValues`, `deleteCommissionLines`).
|
|
38
|
+
|
|
39
|
+
## Calculation & line methods
|
|
40
|
+
|
|
41
|
+
| Method | Description |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| `getCommissionLines(context)` | Resolve the commission lines for a calculation context (items + shipping in a currency), most-specific-wins, without persisting |
|
|
44
|
+
| `upsertCommissionLines(lines)` | Replace lines by anchor (`item_id` / `shipping_method_id`), making refreshes idempotent |
|
|
45
|
+
|
|
46
|
+
<Warning>
|
|
47
|
+
Prefer [workflows](/platform/commission/reference/workflows) for order-line
|
|
48
|
+
refreshes and rate deletion. `refreshOrderCommissionLinesWorkflow` builds the
|
|
49
|
+
calculation context from the order and calls these methods for you;
|
|
50
|
+
`deleteCommissionRatesWorkflow` validates that a rate is safe to delete first.
|
|
51
|
+
</Warning>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Workflows"
|
|
3
|
+
sidebarTitle: "Workflows"
|
|
4
|
+
description: "Commission rate, rule, and order-line workflows."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
This reference lists the workflows for the Commission domain. Import them from
|
|
8
|
+
`@mercurjs/core/workflows` and run them against the Medusa container.
|
|
9
|
+
|
|
10
|
+
## Rate workflows
|
|
11
|
+
|
|
12
|
+
| Workflow | Input | Purpose |
|
|
13
|
+
| --- | --- | --- |
|
|
14
|
+
| `createCommissionRatesWorkflow` | `CreateCommissionRateDTO[]` | Create rates (auto-generates `code`) |
|
|
15
|
+
| `updateCommissionRatesWorkflow` | `UpdateCommissionRateDTO[]` | Update rate fields |
|
|
16
|
+
| `deleteCommissionRatesWorkflow` | `{ ids[] }` | Delete rates (validates deletability first) |
|
|
17
|
+
|
|
18
|
+
## Rule workflows
|
|
19
|
+
|
|
20
|
+
| Workflow | Input | Purpose |
|
|
21
|
+
| --- | --- | --- |
|
|
22
|
+
| `batchCommissionRulesWorkflow` | `{ commission_rate_id, create?, update?, delete? }` | Create, update, and delete a rate's rules in one call |
|
|
23
|
+
|
|
24
|
+
## Order-line workflows
|
|
25
|
+
|
|
26
|
+
| Workflow | Input | Purpose |
|
|
27
|
+
| --- | --- | --- |
|
|
28
|
+
| `refreshOrderCommissionLinesWorkflow` | `{ order_ids[] }` | Recompute and upsert an order's commission lines (idempotent) |
|
|
29
|
+
|
|
30
|
+
<Note>
|
|
31
|
+
`deleteCommissionRatesWorkflow` exposes a `commissionRatesDeleted` hook, and
|
|
32
|
+
`batchCommissionRulesWorkflow` runs its create / update / delete steps in
|
|
33
|
+
parallel. `refreshOrderCommissionLinesWorkflow` also runs as a step inside the
|
|
34
|
+
cart-split checkout workflow.
|
|
35
|
+
</Note>
|
|
36
|
+
|
|
37
|
+
To work with records directly instead of through a workflow, see the
|
|
38
|
+
[Service reference](/platform/commission/reference/service). To run side effects
|
|
39
|
+
when an order changes, see the
|
|
40
|
+
[Event reference](/platform/commission/reference/events).
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Pricing & inventory"
|
|
3
|
+
sidebarTitle: "Pricing & inventory"
|
|
4
|
+
description: "Offer-scoped prices on the shared price set, and inventory linked to the offer."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
In this document, you'll learn how an offer carries its own price and inventory
|
|
8
|
+
without owning the master variant.
|
|
9
|
+
|
|
10
|
+
## Offer-scoped pricing
|
|
11
|
+
|
|
12
|
+
An offer's prices don't live on a private price set. They live on the **master
|
|
13
|
+
variant's shared `PriceSet`**, with each offer-owned row scoped by a
|
|
14
|
+
`PriceRule` on the `offer_id` attribute. That's how many stores price the same
|
|
15
|
+
variant independently: every price row Mercur writes for an offer is stamped with
|
|
16
|
+
that offer's id, and reads filter the set back down to just that offer's rows.
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
// Every offer price row is written with an offer_id rule on the shared price set
|
|
20
|
+
prices: [
|
|
21
|
+
{
|
|
22
|
+
amount: 2500,
|
|
23
|
+
currency_code: "usd",
|
|
24
|
+
rules: { offer_id: "offer_123" },
|
|
25
|
+
},
|
|
26
|
+
]
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The offer side reads its price ladder through the writable `offer ↔ price`
|
|
30
|
+
list-link, so `offer.prices` resolves in a single query traversal. Each row is a
|
|
31
|
+
standard Medusa money amount and supports `min_quantity` / `max_quantity` for
|
|
32
|
+
quantity-break pricing.
|
|
33
|
+
|
|
34
|
+
<Note>
|
|
35
|
+
Because prices sit on the shared price set scoped by `offer_id`, the master
|
|
36
|
+
variant is never mutated per store. The variant keeps a single price set, and
|
|
37
|
+
the `offer_id` rule partitions it per offer.
|
|
38
|
+
</Note>
|
|
39
|
+
|
|
40
|
+
## Offer-scoped inventory
|
|
41
|
+
|
|
42
|
+
An offer's stock is held in Medusa `InventoryItem` records that link to the
|
|
43
|
+
**offer**, not to the variant. The `offer ↔ inventory_item` link is a list-link
|
|
44
|
+
whose pivot table (`offer_inventory_item`) carries a `required_quantity` column,
|
|
45
|
+
so one offer can draw on several inventory items, each with its own required
|
|
46
|
+
quantity.
|
|
47
|
+
|
|
48
|
+
<Warning>
|
|
49
|
+
Offer inventory links to the **offer**, not the variant. `variant.inventory_items`
|
|
50
|
+
is empty for offer-based orders. Always resolve stock through
|
|
51
|
+
`offer.inventory_items`, never through the variant.
|
|
52
|
+
</Warning>
|
|
53
|
+
|
|
54
|
+
When you create an offer, its `inventory_items` entries each create a brand-new
|
|
55
|
+
`InventoryItem` (with optional starting `stock_levels`) and link it to the offer
|
|
56
|
+
in the same workflow run. An offer must have at least one inventory item.
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
inventory_items: [
|
|
60
|
+
{
|
|
61
|
+
sku: "ACME-WIDGET-01",
|
|
62
|
+
required_quantity: 1,
|
|
63
|
+
stock_levels: [{ location_id: "sloc_1", stocked_quantity: 50 }],
|
|
64
|
+
},
|
|
65
|
+
]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
<Tip>
|
|
69
|
+
The inventory items an offer creates are also linked to the store, so they show
|
|
70
|
+
up under the store's inventory. To change the set of items on an existing
|
|
71
|
+
offer, use the [batch inventory workflow](/platform/offer/guides/manage-offer-inventory).
|
|
72
|
+
</Tip>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Shipping"
|
|
3
|
+
sidebarTitle: "Shipping"
|
|
4
|
+
description: "How an offer carries its own shipping profile."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
In this document, you'll learn how an offer determines how its items ship.
|
|
8
|
+
|
|
9
|
+
## Shipping profile
|
|
10
|
+
|
|
11
|
+
Every offer points at a store's own **shipping profile** through its
|
|
12
|
+
`shipping_profile_id` field, joined via the read-only `offer ↔ shipping_profile`
|
|
13
|
+
link. The profile is what ties the offer's items to the store's shipping options
|
|
14
|
+
at checkout, so each store fulfills its slice of a multi-seller cart with its own
|
|
15
|
+
rates.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
await createOffersWorkflow(container).run({
|
|
19
|
+
input: {
|
|
20
|
+
offers: [
|
|
21
|
+
{
|
|
22
|
+
seller_id: "sel_123",
|
|
23
|
+
created_by: "mem_123",
|
|
24
|
+
variant_id: "variant_123",
|
|
25
|
+
shipping_profile_id: "sp_123",
|
|
26
|
+
sku: "ACME-WIDGET-01",
|
|
27
|
+
prices: [{ amount: 2500, currency_code: "usd" }],
|
|
28
|
+
inventory_items: [{ stock_levels: [{ location_id: "sloc_1", stocked_quantity: 50 }] }],
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Master products carry no profile
|
|
36
|
+
|
|
37
|
+
Master products live in the shared catalog and have no shipping profile of their
|
|
38
|
+
own. To keep multi-seller carts from losing their shipping methods on refresh,
|
|
39
|
+
`createOffersWorkflow` links the offer's **master product** to the offer's
|
|
40
|
+
shipping profile. The product↔profile link is one-to-one, so the first offer's
|
|
41
|
+
profile wins for a given master product. Later offers (including other stores'
|
|
42
|
+
offers on the same product) skip the link if a profile is already attached.
|
|
43
|
+
|
|
44
|
+
<Note>
|
|
45
|
+
The one-to-one product↔profile link is a checkout-refresh accommodation, not
|
|
46
|
+
the source of truth for how a store ships. Each offer still carries its own
|
|
47
|
+
`shipping_profile_id`, which is what drives that store's fulfillment.
|
|
48
|
+
</Note>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "What is an offer"
|
|
3
|
+
sidebarTitle: "What is an offer"
|
|
4
|
+
description: "The offer record, how it points at a master product variant, and its SKU."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
In this document, you'll learn what an offer is and how it relates to the shared
|
|
8
|
+
master catalog.
|
|
9
|
+
|
|
10
|
+
## Offer
|
|
11
|
+
|
|
12
|
+
An offer is a store's listing against a master product variant, represented by
|
|
13
|
+
the `Offer` data model (table `offer`, id prefix `offer`). It's a thin
|
|
14
|
+
marketplace-side record: it holds the store (`seller_id`), the master variant it
|
|
15
|
+
points at (`variant_id`), the master product (`product_id`), the store's own
|
|
16
|
+
`sku`, optional `ean` / `upc` barcodes, and the shipping profile it ships with.
|
|
17
|
+
Price and inventory are attached through links rather than stored on the row.
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
const { result } = await createOffersWorkflow(container).run({
|
|
21
|
+
input: {
|
|
22
|
+
offers: [
|
|
23
|
+
{
|
|
24
|
+
seller_id: "sel_123",
|
|
25
|
+
created_by: "mem_123",
|
|
26
|
+
variant_id: "variant_123",
|
|
27
|
+
shipping_profile_id: "sp_123",
|
|
28
|
+
sku: "ACME-WIDGET-01",
|
|
29
|
+
prices: [{ amount: 2500, currency_code: "usd" }],
|
|
30
|
+
inventory_items: [{ stock_levels: [{ location_id: "sloc_1", stocked_quantity: 50 }] }],
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
<Note>
|
|
38
|
+
**Products are not seller-owned.** The master product and its variants live in
|
|
39
|
+
the shared catalog. An offer never modifies the product. It points at a
|
|
40
|
+
variant and layers the store's own commercial terms on top.
|
|
41
|
+
</Note>
|
|
42
|
+
|
|
43
|
+
## Offer vs. master product
|
|
44
|
+
|
|
45
|
+
A single master variant can back many offers, one per store that sells it. The
|
|
46
|
+
`Offer` carries the identity of that particular listing:
|
|
47
|
+
|
|
48
|
+
- `product_id` / `variant_id`: the master records the offer points at (joined through read-only links).
|
|
49
|
+
- `seller_id`: the store that owns the offer (read-only link to the store).
|
|
50
|
+
- `sku`: the store's own stock-keeping unit for this listing.
|
|
51
|
+
- `ean` / `upc`: barcodes, snapshotted off the linked variant when not supplied.
|
|
52
|
+
|
|
53
|
+
<Tip>
|
|
54
|
+
A store's `sku` is **unique within that store** (`(seller_id, sku)`, enforced
|
|
55
|
+
while `deleted_at IS NULL`). Two different stores may reuse the same SKU string
|
|
56
|
+
for their own offers.
|
|
57
|
+
</Tip>
|
|
58
|
+
|
|
59
|
+
## One offer per variant
|
|
60
|
+
|
|
61
|
+
Each offer points at exactly one variant, so a store's offers on a product mirror
|
|
62
|
+
that product's variants. When offers are grouped by store
|
|
63
|
+
(`group_by_seller`), the service computes a `variant_count` and an `offer_ids`
|
|
64
|
+
list for the grouped `(product, seller)` row. The dashboards use it to act on
|
|
65
|
+
all of a store's offers on a product at once.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Bulk-create offers"
|
|
3
|
+
sidebarTitle: "Bulk-create offers"
|
|
4
|
+
description: "List many offers against the master catalog in a single workflow run."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
In this guide, you'll learn how to create many offers at once, for example when
|
|
8
|
+
onboarding a store's catalog or running a CSV import.
|
|
9
|
+
|
|
10
|
+
`createOffersWorkflow` accepts an array of offers, so a single run can list a
|
|
11
|
+
store against many master variants at once. Each entry is independent and carries
|
|
12
|
+
its own SKU, prices, inventory, and shipping profile.
|
|
13
|
+
|
|
14
|
+
## Run the workflow with many offers
|
|
15
|
+
|
|
16
|
+
```ts title="src/api/custom/bulk/route.ts"
|
|
17
|
+
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
|
18
|
+
import { createOffersWorkflow } from "@mercurjs/core/workflows"
|
|
19
|
+
|
|
20
|
+
export async function POST(req: MedusaRequest, res: MedusaResponse) {
|
|
21
|
+
const { result } = await createOffersWorkflow(req.scope).run({
|
|
22
|
+
input: {
|
|
23
|
+
offers: [
|
|
24
|
+
{
|
|
25
|
+
seller_id: "sel_123",
|
|
26
|
+
created_by: "mem_123",
|
|
27
|
+
variant_id: "variant_a",
|
|
28
|
+
shipping_profile_id: "sp_123",
|
|
29
|
+
sku: "ACME-A-01",
|
|
30
|
+
prices: [{ amount: 2500, currency_code: "usd" }],
|
|
31
|
+
inventory_items: [{ stock_levels: [{ location_id: "sloc_1", stocked_quantity: 50 }] }],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
seller_id: "sel_123",
|
|
35
|
+
created_by: "mem_123",
|
|
36
|
+
variant_id: "variant_b",
|
|
37
|
+
shipping_profile_id: "sp_123",
|
|
38
|
+
sku: "ACME-B-01",
|
|
39
|
+
prices: [{ amount: 4000, currency_code: "usd" }],
|
|
40
|
+
inventory_items: [{ stock_levels: [{ location_id: "sloc_1", stocked_quantity: 20 }] }],
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
res.status(201).json({ offers: result })
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
<Warning>
|
|
51
|
+
The batch is validated as a whole: if any entry references a missing variant,
|
|
52
|
+
omits its inventory items, or reuses an existing `(seller_id, sku)` pair, the
|
|
53
|
+
run fails and its steps are compensated, so no partial offers are left behind.
|
|
54
|
+
</Warning>
|
|
55
|
+
|
|
56
|
+
## Update many offers
|
|
57
|
+
|
|
58
|
+
`updateOffersWorkflow` mirrors the same array shape for edits. Each entry is
|
|
59
|
+
keyed by the offer `id`; supplying a `prices` array **replaces** the offer's
|
|
60
|
+
price ladder (rows with an `id` are updated in place, rows without one are added,
|
|
61
|
+
and omitted rows are removed), while leaving `prices` out keeps the ladder
|
|
62
|
+
untouched.
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { updateOffersWorkflow } from "@mercurjs/core/workflows"
|
|
66
|
+
|
|
67
|
+
await updateOffersWorkflow(req.scope).run({
|
|
68
|
+
input: {
|
|
69
|
+
offers: [
|
|
70
|
+
{ id: "offer_a", sku: "ACME-A-02" },
|
|
71
|
+
{
|
|
72
|
+
id: "offer_b",
|
|
73
|
+
prices: [{ amount: 3500, currency_code: "usd" }],
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
})
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
<Tip>
|
|
81
|
+
Both workflows emit one event per affected offer (`offer.created` /
|
|
82
|
+
`offer.updated`). Subscribe to those events to run downstream side effects like
|
|
83
|
+
re-indexing search. See the [Event reference](/platform/offer/reference/events).
|
|
84
|
+
</Tip>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Create an offer"
|
|
3
|
+
sidebarTitle: "Create an offer"
|
|
4
|
+
description: "Create a single offer programmatically with createOffersWorkflow."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
In this guide, you'll learn how to create an offer from your own server code,
|
|
8
|
+
for example in a custom API route, a seed script, or an import flow.
|
|
9
|
+
|
|
10
|
+
Mercur exposes a `createOffersWorkflow` that creates the `Offer` record, its
|
|
11
|
+
inventory items, and its price rows, and wires up every link in one run. Run it
|
|
12
|
+
from any place that has access to the Medusa container.
|
|
13
|
+
|
|
14
|
+
## Run the workflow
|
|
15
|
+
|
|
16
|
+
```ts title="src/api/custom/route.ts"
|
|
17
|
+
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
|
18
|
+
import { createOffersWorkflow } from "@mercurjs/core/workflows"
|
|
19
|
+
|
|
20
|
+
export async function POST(req: MedusaRequest, res: MedusaResponse) {
|
|
21
|
+
const { result } = await createOffersWorkflow(req.scope).run({
|
|
22
|
+
input: {
|
|
23
|
+
offers: [
|
|
24
|
+
{
|
|
25
|
+
seller_id: "sel_123",
|
|
26
|
+
created_by: "mem_123",
|
|
27
|
+
variant_id: "variant_123",
|
|
28
|
+
shipping_profile_id: "sp_123",
|
|
29
|
+
sku: "ACME-WIDGET-01",
|
|
30
|
+
prices: [{ amount: 2500, currency_code: "usd" }],
|
|
31
|
+
inventory_items: [
|
|
32
|
+
{
|
|
33
|
+
stock_levels: [{ location_id: "sloc_1", stocked_quantity: 50 }],
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
res.status(201).json({ offer: result[0] })
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
<Note>
|
|
46
|
+
Each offer must reference an existing master `variant_id` and include at least
|
|
47
|
+
one `inventory_items` entry. The SKU must be unique within the store.
|
|
48
|
+
Reusing an existing `(seller_id, sku)` pair is rejected.
|
|
49
|
+
</Note>
|
|
50
|
+
|
|
51
|
+
## What the workflow wires up
|
|
52
|
+
|
|
53
|
+
A single run does more than insert a row:
|
|
54
|
+
|
|
55
|
+
- Creates a new `InventoryItem` per `inventory_items` entry (with any `stock_levels`) and links each to the offer. Remember, inventory links to the **offer**, not the variant.
|
|
56
|
+
- Writes each price onto the master variant's shared price set, stamped with an `offer_id` rule, and links the price rows to the offer.
|
|
57
|
+
- Links the offer to its store, product, variant, and shipping profile.
|
|
58
|
+
- Emits `offer.created`.
|
|
59
|
+
|
|
60
|
+
## Attach custom data
|
|
61
|
+
|
|
62
|
+
The workflow accepts an `additional_data` payload that is passed to its
|
|
63
|
+
`offersCreated` hook, letting you persist marketplace-specific data alongside the
|
|
64
|
+
offer without forking the workflow.
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
await createOffersWorkflow(req.scope).run({
|
|
68
|
+
input: {
|
|
69
|
+
offers: [
|
|
70
|
+
{
|
|
71
|
+
seller_id: "sel_123",
|
|
72
|
+
created_by: "mem_123",
|
|
73
|
+
variant_id: "variant_123",
|
|
74
|
+
shipping_profile_id: "sp_123",
|
|
75
|
+
sku: "ACME-WIDGET-01",
|
|
76
|
+
prices: [{ amount: 2500, currency_code: "usd" }],
|
|
77
|
+
inventory_items: [{ stock_levels: [{ location_id: "sloc_1", stocked_quantity: 50 }] }],
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
additional_data: { source: "csv-import" },
|
|
81
|
+
},
|
|
82
|
+
})
|
|
83
|
+
```
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Manage offer inventory"
|
|
3
|
+
sidebarTitle: "Manage offer inventory"
|
|
4
|
+
description: "Attach, update, and detach inventory items on an existing offer."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
In this guide, you'll learn how to change the inventory items linked to an
|
|
8
|
+
existing offer from your own server code.
|
|
9
|
+
|
|
10
|
+
Because inventory links to the **offer** (not the variant), the set of inventory
|
|
11
|
+
items backing an offer is managed through the `offer ↔ inventory_item` link.
|
|
12
|
+
`batchOfferInventoryItemsWorkflow` applies creates, updates, and deletes to that
|
|
13
|
+
link in a single run.
|
|
14
|
+
|
|
15
|
+
## Run the batch workflow
|
|
16
|
+
|
|
17
|
+
```ts title="src/api/custom/offer-inventory/route.ts"
|
|
18
|
+
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
|
19
|
+
import { batchOfferInventoryItemsWorkflow } from "@mercurjs/core/workflows"
|
|
20
|
+
|
|
21
|
+
export async function POST(req: MedusaRequest, res: MedusaResponse) {
|
|
22
|
+
const { result } = await batchOfferInventoryItemsWorkflow(req.scope).run({
|
|
23
|
+
input: {
|
|
24
|
+
offer_id: "offer_123",
|
|
25
|
+
create: [{ inventory_item_id: "iitem_new", required_quantity: 2 }],
|
|
26
|
+
update: [{ inventory_item_id: "iitem_existing", required_quantity: 5 }],
|
|
27
|
+
delete: ["iitem_stale"],
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
res.json(result)
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The result reports the links that were `created`, `updated`, and `deleted`.
|
|
36
|
+
|
|
37
|
+
## Rules the workflow enforces
|
|
38
|
+
|
|
39
|
+
- Items in `create` must **not** already be linked to the offer; items in `update` and `delete` **must** already be linked.
|
|
40
|
+
- An `inventory_item_id` can't appear in more than one section, and can't be duplicated within a section.
|
|
41
|
+
- `create` items must reference existing `InventoryItem` records; `required_quantity` defaults to `1`.
|
|
42
|
+
- Deleting an item that isn't linked to the offer surfaces a 404 rather than silently no-op'ing.
|
|
43
|
+
|
|
44
|
+
<Note>
|
|
45
|
+
This workflow manages the **links** between an offer and existing inventory
|
|
46
|
+
items and their `required_quantity`. To create brand-new inventory items with
|
|
47
|
+
starting stock as part of listing an offer, pass `inventory_items` to
|
|
48
|
+
[`createOffersWorkflow`](/platform/offer/guides/create-an-offer) instead.
|
|
49
|
+
</Note>
|
|
50
|
+
|
|
51
|
+
The workflow emits `offer.updated` and exposes an `offerInventoryItemsBatched`
|
|
52
|
+
hook carrying the `offer_id`, the batch result, and any `additional_data` you
|
|
53
|
+
passed in.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Offer"
|
|
3
|
+
sidebarTitle: "Overview"
|
|
4
|
+
description: "How a store sells against the shared master catalog, with its own SKU, price, inventory, and shipping."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Use offers to let each store sell against Mercur's shared master catalog on its
|
|
8
|
+
own terms.
|
|
9
|
+
|
|
10
|
+
The offer is the central concept of the marketplace. Products live in a single
|
|
11
|
+
**master catalog** that no store owns; an offer is the record that connects a
|
|
12
|
+
store to a master product variant. It carries everything that makes that listing
|
|
13
|
+
the store's own: its SKU, its price, its inventory, and its shipping profile.
|
|
14
|
+
Cart and order line items link back to the exact offer that was purchased, so the
|
|
15
|
+
whole order lifecycle knows which store fulfills and gets paid.
|
|
16
|
+
|
|
17
|
+
<Note>
|
|
18
|
+
**Products are shared; offers are owned.** A store never owns a product. It
|
|
19
|
+
publishes an offer against a master product variant. Two stores selling the
|
|
20
|
+
same product each have their own offer, with their own SKU, price, and stock.
|
|
21
|
+
</Note>
|
|
22
|
+
|
|
23
|
+
## Key features
|
|
24
|
+
|
|
25
|
+
- **Per-store listings:** one offer per store per variant, each with its own SKU (unique within a store).
|
|
26
|
+
- **Offer-scoped pricing:** prices live on the master variant's shared price set, scoped by an `offer_id` rule so every store prices independently.
|
|
27
|
+
- **Offer-scoped inventory:** inventory items link to the **offer**, not the variant, so stock never leaks between stores.
|
|
28
|
+
- **Per-offer shipping:** each offer points at the store's own shipping profile.
|
|
29
|
+
- **Order attribution:** cart and order line items link to the purchased offer, driving fulfillment, commission, and payouts.
|
|
30
|
+
- **Bulk operations:** create and update many offers, and batch an offer's inventory links, in a single workflow run.
|
|
31
|
+
|
|
32
|
+
## Get started
|
|
33
|
+
|
|
34
|
+
Learn how the domain fits together:
|
|
35
|
+
|
|
36
|
+
<CardGroup cols={2}>
|
|
37
|
+
<Card title="What is an offer" icon="tag" href="/platform/offer/concepts/what-is-an-offer">
|
|
38
|
+
The offer record, how it points at a master variant, and its SKU.
|
|
39
|
+
</Card>
|
|
40
|
+
<Card title="Pricing & inventory" icon="coins" href="/platform/offer/concepts/pricing-and-inventory">
|
|
41
|
+
Offer-scoped prices on the shared price set and offer-linked inventory.
|
|
42
|
+
</Card>
|
|
43
|
+
<Card title="Shipping" icon="truck" href="/platform/offer/concepts/shipping">
|
|
44
|
+
How an offer carries its own shipping profile.
|
|
45
|
+
</Card>
|
|
46
|
+
</CardGroup>
|
|
47
|
+
|
|
48
|
+
## Examples
|
|
49
|
+
|
|
50
|
+
Build against the Offer domain in your own code:
|
|
51
|
+
|
|
52
|
+
<CardGroup cols={2}>
|
|
53
|
+
<Card title="Create an offer" icon="plus" href="/platform/offer/guides/create-an-offer">
|
|
54
|
+
Run `createOffersWorkflow` with a price and inventory.
|
|
55
|
+
</Card>
|
|
56
|
+
<Card title="Bulk-create offers" icon="layer-group" href="/platform/offer/guides/bulk-create-offers">
|
|
57
|
+
List many offers against the catalog in one run.
|
|
58
|
+
</Card>
|
|
59
|
+
<Card title="Manage offer inventory" icon="boxes-stacked" href="/platform/offer/guides/manage-offer-inventory">
|
|
60
|
+
Attach, update, and detach inventory items on an offer.
|
|
61
|
+
</Card>
|
|
62
|
+
</CardGroup>
|
|
63
|
+
|
|
64
|
+
## Resources
|
|
65
|
+
|
|
66
|
+
Data models, workflows, service methods, and events for the Offer domain:
|
|
67
|
+
|
|
68
|
+
<CardGroup cols={2}>
|
|
69
|
+
<Card title="Data models" icon="table" href="/platform/offer/reference/data-models">
|
|
70
|
+
The `Offer` entity and its fields.
|
|
71
|
+
</Card>
|
|
72
|
+
<Card title="Links" icon="link" href="/platform/offer/reference/links">
|
|
73
|
+
How the Offer domain links to other modules.
|
|
74
|
+
</Card>
|
|
75
|
+
<Card title="Workflows" icon="diagram-project" href="/platform/offer/reference/workflows">
|
|
76
|
+
Create, update, delete, and inventory-batch workflows.
|
|
77
|
+
</Card>
|
|
78
|
+
<Card title="Service" icon="gear" href="/platform/offer/reference/service">
|
|
79
|
+
Module service methods for working with records directly.
|
|
80
|
+
</Card>
|
|
81
|
+
<Card title="Events" icon="bell" href="/platform/offer/reference/events">
|
|
82
|
+
Events emitted as offers change.
|
|
83
|
+
</Card>
|
|
84
|
+
</CardGroup>
|