@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,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Data models"
|
|
3
|
+
sidebarTitle: "Data models"
|
|
4
|
+
description: "The data models owned by the Offer domain."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
The Offer domain is owned by the **Offer module**. This reference lists its data
|
|
8
|
+
model and fields. For the full module overview, see the
|
|
9
|
+
[Offer overview](/platform/offer/overview).
|
|
10
|
+
|
|
11
|
+
## Offer
|
|
12
|
+
|
|
13
|
+
Table `offer`, id prefix `offer`. A store's listing against a master product
|
|
14
|
+
variant. Price and inventory are attached through links rather than stored on the
|
|
15
|
+
row.
|
|
16
|
+
|
|
17
|
+
| Field | Type | Notes |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| `id` | text | Primary key |
|
|
20
|
+
| `seller_id` | text | The store that owns the offer (read-only link) |
|
|
21
|
+
| `variant_id` | text | The master `ProductVariant` the offer points at |
|
|
22
|
+
| `product_id` | text | The master `Product` the variant belongs to |
|
|
23
|
+
| `shipping_profile_id` | text | The store's shipping profile for this offer |
|
|
24
|
+
| `sku` | text | Searchable; unique within a store (see below) |
|
|
25
|
+
| `ean` | text | Nullable, searchable; snapshotted off the variant when omitted |
|
|
26
|
+
| `upc` | text | Nullable, searchable; snapshotted off the variant when omitted |
|
|
27
|
+
| `created_by` | text | The member that created the offer |
|
|
28
|
+
| `variant_count` | number | Computed; only set when grouping by store |
|
|
29
|
+
| `metadata` | json | Nullable |
|
|
30
|
+
|
|
31
|
+
Uniqueness: `(seller_id, sku)` is unique while `deleted_at IS NULL`, so a store
|
|
32
|
+
can't reuse a SKU across its live offers, but different stores may share SKU
|
|
33
|
+
strings. Indexes also cover `variant_id`, `product_id`, `seller_id`,
|
|
34
|
+
`shipping_profile_id`, `ean`, and `upc`.
|
|
35
|
+
|
|
36
|
+
## Linked data
|
|
37
|
+
|
|
38
|
+
The offer's price ladder, inventory, and related records aren't columns on the
|
|
39
|
+
`offer` table. They're joined through links and only present when requested:
|
|
40
|
+
|
|
41
|
+
| Relation | Source |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| `prices` | Offer-owned rows on the master variant's shared price set (`offer ↔ price` list-link) |
|
|
44
|
+
| `inventory_items` | `offer ↔ inventory_item` list-link; each row carries `required_quantity` |
|
|
45
|
+
| `seller` | Read-only `offer ↔ seller` link |
|
|
46
|
+
| `product` / `product_variant` | Read-only `offer ↔ product` / `offer ↔ variant` links |
|
|
47
|
+
| `shipping_profile` | Read-only `offer ↔ shipping_profile` link |
|
|
48
|
+
|
|
49
|
+
<Note>
|
|
50
|
+
`variant_count` (and the companion `offer_ids` list) are computed only when
|
|
51
|
+
offers are listed grouped by store (`group_by_seller`). On ungrouped reads they
|
|
52
|
+
are absent.
|
|
53
|
+
</Note>
|
|
54
|
+
|
|
55
|
+
See the [Links reference](/platform/offer/reference/links) for the full set of
|
|
56
|
+
module links.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Event reference"
|
|
3
|
+
sidebarTitle: "Events"
|
|
4
|
+
description: "Events emitted by the Offer domain, for subscribers and side effects."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
The Offer domain emits events as offers change. Subscribe to them to run side
|
|
8
|
+
effects instead of polling, such as re-indexing search, syncing external
|
|
9
|
+
systems, or kicking off follow-up workflows.
|
|
10
|
+
|
|
11
|
+
```ts title="src/subscribers/offer-created.ts"
|
|
12
|
+
import type { SubscriberArgs, SubscriberConfig } from "@medusajs/framework"
|
|
13
|
+
|
|
14
|
+
export default async function offerCreatedHandler({
|
|
15
|
+
event,
|
|
16
|
+
container,
|
|
17
|
+
}: SubscriberArgs<{ id: string; product_id: string }>) {
|
|
18
|
+
const offerId = event.data.id
|
|
19
|
+
// ...re-index the offer, notify the store, etc.
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const config: SubscriberConfig = {
|
|
23
|
+
event: "offer.created",
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Offer events
|
|
28
|
+
|
|
29
|
+
| Event | Emitted when | Payload |
|
|
30
|
+
| --- | --- | --- |
|
|
31
|
+
| `offer.created` | An offer is created | `{ id, product_id }` |
|
|
32
|
+
| `offer.updated` | An offer's row, prices, or inventory links change | `{ id, product_id }` |
|
|
33
|
+
| `offer.deleted` | An offer is deleted | `{ id, product_id }` |
|
|
34
|
+
|
|
35
|
+
<Note>
|
|
36
|
+
`createOffersWorkflow` and `updateOffersWorkflow` emit one event per affected
|
|
37
|
+
offer. `batchOfferInventoryItemsWorkflow` emits `offer.updated` with a single
|
|
38
|
+
`{ id }` payload for the batched offer.
|
|
39
|
+
</Note>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Links to other modules"
|
|
3
|
+
sidebarTitle: "Links"
|
|
4
|
+
description: "How the Offer domain links to other modules across the marketplace."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Modules in Mercur never reference each other directly. They connect through
|
|
8
|
+
**module links**. The offer sits at the center of the marketplace, so it links
|
|
9
|
+
out to the store, the master catalog, pricing, inventory, fulfillment, and the
|
|
10
|
+
cart and order line items that reference it. Once a link is defined, you retrieve
|
|
11
|
+
related records with `query.graph` using the link alias.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
const { data: offers } = await query.graph({
|
|
15
|
+
entity: "offer",
|
|
16
|
+
fields: ["id", "sku", "prices.*", "inventory_items.*", "seller.name"],
|
|
17
|
+
})
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Catalog & store
|
|
21
|
+
|
|
22
|
+
| Linked module | Relationship |
|
|
23
|
+
| --- | --- |
|
|
24
|
+
| **Product** | An offer points at one master product (`offer.product_id`, read-only). |
|
|
25
|
+
| **Product variant** | An offer points at one master variant (`offer.variant_id`, read-only). |
|
|
26
|
+
| **Seller** | An offer belongs to one store (`offer.seller_id`, read-only). |
|
|
27
|
+
|
|
28
|
+
## Pricing & inventory
|
|
29
|
+
|
|
30
|
+
| Linked module | Relationship |
|
|
31
|
+
| --- | --- |
|
|
32
|
+
| **Price** | An offer has many prices: a writable list-link to the offer-owned rows on the master variant's shared price set. |
|
|
33
|
+
| **Inventory item** | An offer has many inventory items: a writable list-link (`offer_inventory_item`) whose pivot carries a `required_quantity` column. |
|
|
34
|
+
|
|
35
|
+
## Fulfillment
|
|
36
|
+
|
|
37
|
+
| Linked module | Relationship |
|
|
38
|
+
| --- | --- |
|
|
39
|
+
| **Shipping profile** | An offer ships with one shipping profile (`offer.shipping_profile_id`, read-only). |
|
|
40
|
+
|
|
41
|
+
## Cart & order
|
|
42
|
+
|
|
43
|
+
| Linked module | Relationship |
|
|
44
|
+
| --- | --- |
|
|
45
|
+
| **Cart line item** | A cart line item links to the offer it added; one offer can back many cart line items (list-link on the line-item side). |
|
|
46
|
+
| **Order line item** | An order line item links to the purchased offer; one offer can back many order line items across child orders (list-link on the line-item side). |
|
|
47
|
+
|
|
48
|
+
<Note>
|
|
49
|
+
Read-only links (Product, Variant, Seller, Shipping profile) resolve from a
|
|
50
|
+
field on the `offer` row and can't be written through the link itself. The
|
|
51
|
+
Price and Inventory-item links are writable and are managed by the offer
|
|
52
|
+
workflows.
|
|
53
|
+
</Note>
|
|
54
|
+
|
|
55
|
+
<Tip>
|
|
56
|
+
The cart- and order-line-item links are list-links **on the line-item side** so
|
|
57
|
+
the same offer can be added to many carts and placed on many orders. Without
|
|
58
|
+
that, Medusa would enforce a 1:1 line-item ↔ offer relationship and block
|
|
59
|
+
re-use.
|
|
60
|
+
</Tip>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Service reference"
|
|
3
|
+
sidebarTitle: "Service"
|
|
4
|
+
description: "The Offer module service and its methods for working with records directly."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
The Offer module exposes a service you can resolve from the Medusa container to
|
|
8
|
+
read and write records directly, without going through a workflow. Use it inside
|
|
9
|
+
custom services, subscribers, or scheduled jobs.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { MercurModules } from "@mercurjs/types"
|
|
13
|
+
|
|
14
|
+
const offerModuleService = container.resolve(MercurModules.OFFER)
|
|
15
|
+
|
|
16
|
+
const [offers, count] = await offerModuleService.listAndCountOffers({
|
|
17
|
+
seller_id: "sel_123",
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Generated methods
|
|
22
|
+
|
|
23
|
+
The `Offer` model gets a standard set of auto-generated methods:
|
|
24
|
+
|
|
25
|
+
| Method | Description |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| `createOffers(data)` | Create one or more offers |
|
|
28
|
+
| `retrieveOffer(id, config?)` | Retrieve an offer by id |
|
|
29
|
+
| `listOffers(filters?, config?)` | List offers matching filters |
|
|
30
|
+
| `listAndCountOffers(filters?, config?)` | List offers with a total count |
|
|
31
|
+
| `updateOffers(data)` | Update one or more offers |
|
|
32
|
+
| `deleteOffers(ids)` | Delete one or more offers |
|
|
33
|
+
|
|
34
|
+
## Group by seller
|
|
35
|
+
|
|
36
|
+
`listOffers` and `listAndCountOffers` accept a `group_by_seller` filter. When
|
|
37
|
+
set, the service collapses offers to one row per `(product, seller)` group and
|
|
38
|
+
populates `variant_count` and `offer_ids` on each returned offer.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
const [grouped] = await offerModuleService.listAndCountOffers({
|
|
42
|
+
product_id: "prod_123",
|
|
43
|
+
group_by_seller: true,
|
|
44
|
+
})
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
<Warning>
|
|
48
|
+
The service writes the `offer` row and its computed fields directly. It does
|
|
49
|
+
**not** create the offer's prices, inventory items, or module links, and it
|
|
50
|
+
does **not** emit events or run compensation. Prefer the
|
|
51
|
+
[workflows](/platform/offer/reference/workflows) for anything that must wire up
|
|
52
|
+
pricing, inventory, or links.
|
|
53
|
+
</Warning>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Workflows"
|
|
3
|
+
sidebarTitle: "Workflows"
|
|
4
|
+
description: "Offer workflows for creating, updating, deleting, and batching inventory."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
This reference lists the workflows for the Offer domain. Import them from
|
|
8
|
+
`@mercurjs/core/workflows` and run them against the Medusa container.
|
|
9
|
+
|
|
10
|
+
## Offer workflows
|
|
11
|
+
|
|
12
|
+
| Workflow | Input | Purpose |
|
|
13
|
+
| --- | --- | --- |
|
|
14
|
+
| `createOffersWorkflow` | `{ offers[], additional_data? }` | Create offers with prices, inventory, and links |
|
|
15
|
+
| `updateOffersWorkflow` | `{ offers[], additional_data? }` | Update offer rows and rewrite their price ladders |
|
|
16
|
+
| `deleteOffersWorkflow` | `{ ids[], additional_data? }` | Delete offers |
|
|
17
|
+
| `batchOfferInventoryItemsWorkflow` | `{ offer_id, create?, update?, delete?, additional_data? }` | Add, update, and detach an offer's inventory-item links |
|
|
18
|
+
|
|
19
|
+
## Hooks
|
|
20
|
+
|
|
21
|
+
Each workflow exposes hooks so you can extend it without forking:
|
|
22
|
+
|
|
23
|
+
| Workflow | Hooks |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| `createOffersWorkflow` | `validate`, `offersCreated` |
|
|
26
|
+
| `updateOffersWorkflow` | `validate`, `offersUpdated` |
|
|
27
|
+
| `deleteOffersWorkflow` | `offersDeleted` |
|
|
28
|
+
| `batchOfferInventoryItemsWorkflow` | `validate`, `offerInventoryItemsBatched` |
|
|
29
|
+
|
|
30
|
+
## Behavior notes
|
|
31
|
+
|
|
32
|
+
- **Prices** are written on the master variant's shared price set, each row scoped by an `offer_id` `PriceRule`. On update, supplying `prices` replaces the ladder with the given rows; omitting it leaves prices untouched.
|
|
33
|
+
- **Inventory** items passed to `createOffersWorkflow` are created and linked to the offer (and the store) in the same run. Every offer needs at least one.
|
|
34
|
+
- Workflows run with compensation, so a failed create rolls back the inventory items, prices, and links it had already created.
|
|
35
|
+
|
|
36
|
+
To work with records directly instead of through a workflow, see the
|
|
37
|
+
[Service reference](/platform/offer/reference/service). To run side effects when
|
|
38
|
+
an offer changes, see the [Event reference](/platform/offer/reference/events).
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Computed totals"
|
|
3
|
+
sidebarTitle: "Computed totals"
|
|
4
|
+
description: "Why an order group's seller count and total are derived at query time, not stored."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
This page covers how an order group's `seller_count` and `total` are calculated
|
|
8
|
+
and why they aren't persisted.
|
|
9
|
+
|
|
10
|
+
## Computed, not stored
|
|
11
|
+
|
|
12
|
+
Two fields on the `OrderGroup` model are marked `computed()`. They never hold a
|
|
13
|
+
value in the `order_group` row.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
const OrderGroup = model.define("order_group", {
|
|
17
|
+
// ...
|
|
18
|
+
seller_count: model.number().computed(),
|
|
19
|
+
total: model.bigNumber().computed(),
|
|
20
|
+
})
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`seller_count` is the number of distinct sellers with a child order in the group.
|
|
24
|
+
`total` is the sum of those child orders' current totals. Both are resolved
|
|
25
|
+
by aggregating across the group's linked orders each time the group is read,
|
|
26
|
+
rather than being written once at creation.
|
|
27
|
+
|
|
28
|
+
<Note>
|
|
29
|
+
Storing these values would immediately go stale: child orders can be refunded,
|
|
30
|
+
returned, or canceled after the group is created, changing both the total and,
|
|
31
|
+
effectively, the active seller set.
|
|
32
|
+
</Note>
|
|
33
|
+
|
|
34
|
+
## How they're aggregated
|
|
35
|
+
|
|
36
|
+
When you read a group, the Seller module's order-group repository joins the group
|
|
37
|
+
to its child orders (and each order to its seller and order summary) and folds
|
|
38
|
+
them up:
|
|
39
|
+
|
|
40
|
+
- `seller_count`: a distinct count of the linked sellers
|
|
41
|
+
- `total`: the sum of each child order's current order total
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
const orderGroup = await sellerModuleService.retrieveOrderGroup("og_123")
|
|
45
|
+
// orderGroup.seller_count -> e.g. 3
|
|
46
|
+
// orderGroup.total -> e.g. 24900 (sum across child orders)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
<Tip>
|
|
50
|
+
Because `total` is a `bigNumber`, group totals stay precise no matter how many
|
|
51
|
+
child orders and currencies contribute to the aggregate.
|
|
52
|
+
</Tip>
|
|
53
|
+
|
|
54
|
+
## Aggregated child statuses
|
|
55
|
+
|
|
56
|
+
The retrieve and list workflows layer the same idea onto child orders. They
|
|
57
|
+
derive each order's `payment_status` and `fulfillment_status` from its payment
|
|
58
|
+
collections and fulfillments at read time, so the group reflects the live state
|
|
59
|
+
of every seller's slice without any denormalized status column.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Order splitting"
|
|
3
|
+
sidebarTitle: "Order splitting"
|
|
4
|
+
description: "How a multi-seller cart becomes a group of independent per-seller orders."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
This page covers how a single cart spanning multiple sellers is split into
|
|
8
|
+
per-seller orders at checkout.
|
|
9
|
+
|
|
10
|
+
## Why carts are split
|
|
11
|
+
|
|
12
|
+
A marketplace cart can hold offers from many different sellers. Each seller
|
|
13
|
+
fulfills, ships, and settles independently, so a single combined order would be
|
|
14
|
+
impossible to operate. Instead, on completion the cart is divided along seller
|
|
15
|
+
boundaries. Every seller with items in the cart gets its own `Order`, and all of
|
|
16
|
+
those orders are attached to one parent `OrderGroup`.
|
|
17
|
+
|
|
18
|
+
The split is driven by the `completeCartWithSplitOrdersWorkflow`. It groups the
|
|
19
|
+
cart's line items by the seller behind each offer, and builds one order per
|
|
20
|
+
seller from that seller's items and shipping methods.
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { completeCartWithSplitOrdersWorkflow } from "@mercurjs/core/workflows"
|
|
24
|
+
|
|
25
|
+
const { result } = await completeCartWithSplitOrdersWorkflow(container).run({
|
|
26
|
+
input: { cart_id: "cart_123" },
|
|
27
|
+
})
|
|
28
|
+
// result.order_group_id -> the parent group
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
<Note>
|
|
32
|
+
Items are grouped by `item.offer.seller_id`. Sellers list against the shared
|
|
33
|
+
master catalog through **offers**, so the offer, not the product, is what
|
|
34
|
+
ties a line item to a seller.
|
|
35
|
+
</Note>
|
|
36
|
+
|
|
37
|
+
## What the split produces
|
|
38
|
+
|
|
39
|
+
For each seller in the cart the workflow, in one transaction:
|
|
40
|
+
|
|
41
|
+
- creates a child `Order` with that seller's line items and shipping methods
|
|
42
|
+
- links each order to the group (`order_group_order`) and to its seller (`order_order_seller_seller`)
|
|
43
|
+
- mirrors the line-item → offer links onto the new order lines
|
|
44
|
+
- splits payment captures proportionally across the child orders
|
|
45
|
+
- reserves offer-scoped inventory and refreshes commission lines per order
|
|
46
|
+
|
|
47
|
+
Once every child order is created, the workflow emits `order.placed` for the
|
|
48
|
+
orders and `order_group.created` for the group.
|
|
49
|
+
|
|
50
|
+
<Tip>
|
|
51
|
+
Promotions are attributed per seller: a seller-scoped promotion links only to
|
|
52
|
+
that seller's child order, while marketplace-wide promotions are applied as
|
|
53
|
+
cart adjustments and belong to no single order.
|
|
54
|
+
</Tip>
|
|
55
|
+
|
|
56
|
+
## Independent child orders
|
|
57
|
+
|
|
58
|
+
After the split, each child order lives its own life. Fulfillment, returns, and
|
|
59
|
+
refunds are handled per order, so one seller can ship while another is still
|
|
60
|
+
preparing, without affecting the rest of the group. The group remains the
|
|
61
|
+
single reference the shopper uses to see the purchase as a whole.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "The order group"
|
|
3
|
+
sidebarTitle: "The order group"
|
|
4
|
+
description: "The aggregate record over a multi-seller purchase, its display id, and cart link."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
This page covers the order group record and how it aggregates the per-seller
|
|
8
|
+
orders created from a single cart.
|
|
9
|
+
|
|
10
|
+
## Order group
|
|
11
|
+
|
|
12
|
+
An order group is the shopper-facing wrapper over a multi-seller purchase. It is
|
|
13
|
+
represented by the `OrderGroup` data model (table `order_group`, id prefix
|
|
14
|
+
`og`). When a cart containing offers from more than one seller is completed, the
|
|
15
|
+
cart is split into one child order per seller. All of those orders are attached
|
|
16
|
+
to a single group.
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
const OrderGroup = model.define("order_group", {
|
|
20
|
+
id: model.id({ prefix: "og" }).primaryKey(),
|
|
21
|
+
display_id: model.autoincrement(),
|
|
22
|
+
seller_count: model.number().computed(),
|
|
23
|
+
customer_id: model.text().nullable(),
|
|
24
|
+
total: model.bigNumber().computed(),
|
|
25
|
+
cart_id: model.text(),
|
|
26
|
+
})
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The group carries a human-readable `display_id`, an auto-incrementing integer,
|
|
30
|
+
so shoppers and operators can reference the purchase without exposing the
|
|
31
|
+
internal id. `customer_id` records who placed it. `seller_count` and `total`
|
|
32
|
+
are computed at read time. See [Computed totals](/platform/order-group/concepts/computed-totals).
|
|
33
|
+
|
|
34
|
+
<Note>
|
|
35
|
+
A group is created even for a single-seller cart, so every completed
|
|
36
|
+
marketplace order has exactly one parent group regardless of how many sellers
|
|
37
|
+
it spans.
|
|
38
|
+
</Note>
|
|
39
|
+
|
|
40
|
+
## The cart link
|
|
41
|
+
|
|
42
|
+
Each group holds a `cart_id` pointing back to the cart it was created from. This
|
|
43
|
+
is exposed as a **read-only** link to the Cart module. The cart is frozen
|
|
44
|
+
(`completed_at` is set) the moment the split runs, so the reference is a
|
|
45
|
+
historical record, not something you write through.
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
const { data: groups } = await query.graph({
|
|
49
|
+
entity: "order_group",
|
|
50
|
+
fields: ["id", "display_id", "cart.id", "orders.id"],
|
|
51
|
+
})
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
<Tip>
|
|
55
|
+
Because the cart is immutable after checkout, the `cart_id` is safe to treat as
|
|
56
|
+
a stable audit pointer to the exact basket the shopper paid for.
|
|
57
|
+
</Tip>
|
|
58
|
+
|
|
59
|
+
## Child orders
|
|
60
|
+
|
|
61
|
+
The group doesn't store line items itself. Those live on the child `Order`
|
|
62
|
+
records, linked through the `order_group_order` table. Loading a group's
|
|
63
|
+
`orders.*` gives you each seller's slice, each with its own fulfillment, payment,
|
|
64
|
+
returns, and refunds.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "List order groups"
|
|
3
|
+
sidebarTitle: "List order groups"
|
|
4
|
+
description: "Page through order groups and scope them to a seller with getOrderGroupsListWorkflow."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
In this guide, you'll learn how to list order groups from server code, page
|
|
8
|
+
through the results, and optionally scope them to a single seller.
|
|
9
|
+
|
|
10
|
+
Mercur exposes a `getOrderGroupsListWorkflow` that returns groups with their
|
|
11
|
+
aggregated child orders and a total count for pagination.
|
|
12
|
+
|
|
13
|
+
## Run the workflow
|
|
14
|
+
|
|
15
|
+
```ts title="src/api/custom/order-groups/route.ts"
|
|
16
|
+
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
|
17
|
+
import { getOrderGroupsListWorkflow } from "@mercurjs/core/workflows"
|
|
18
|
+
|
|
19
|
+
export async function GET(req: MedusaRequest, res: MedusaResponse) {
|
|
20
|
+
const { result } = await getOrderGroupsListWorkflow(req.scope).run({
|
|
21
|
+
input: {
|
|
22
|
+
fields: ["id", "display_id", "total", "seller_count"],
|
|
23
|
+
variables: {
|
|
24
|
+
skip: 0,
|
|
25
|
+
take: 20,
|
|
26
|
+
order: { created_at: "DESC" },
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
res.json({
|
|
32
|
+
order_groups: result.rows,
|
|
33
|
+
count: result.metadata?.count ?? 0,
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The workflow returns `{ rows, metadata }`, where `metadata` carries the `count`,
|
|
39
|
+
`skip`, and `take` you need to drive pagination.
|
|
40
|
+
|
|
41
|
+
<Note>
|
|
42
|
+
Filters go inside `variables`: the group repository understands `id`,
|
|
43
|
+
`customer_id`, `seller_id`, `status`, `sales_channel_id`, `created_at`,
|
|
44
|
+
`updated_at`, and a free-text `q` (matched against group id and customer id).
|
|
45
|
+
</Note>
|
|
46
|
+
|
|
47
|
+
## Scope to a seller
|
|
48
|
+
|
|
49
|
+
Pass a `sellerId` to get a vendor's slice. The workflow filters each group's
|
|
50
|
+
child orders down to that seller, so vendors only ever see their own orders
|
|
51
|
+
within a group.
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
await getOrderGroupsListWorkflow(req.scope).run({
|
|
55
|
+
input: {
|
|
56
|
+
fields: ["id", "display_id"],
|
|
57
|
+
variables: { seller_id: "sel_123", take: 20 },
|
|
58
|
+
sellerId: "sel_123",
|
|
59
|
+
},
|
|
60
|
+
})
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
<Tip>
|
|
64
|
+
Admin surfaces call this workflow with no `sellerId` for platform-wide
|
|
65
|
+
visibility. Vendor surfaces pass the resolved seller so both the query and the
|
|
66
|
+
returned child orders stay scoped to that store.
|
|
67
|
+
</Tip>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Retrieve an order group"
|
|
3
|
+
sidebarTitle: "Retrieve an order group"
|
|
4
|
+
description: "Load an order group and its aggregated child orders with getOrderGroupDetailWorkflow."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
In this guide, you'll learn how to load a single order group together with its
|
|
8
|
+
child orders from your own server code.
|
|
9
|
+
|
|
10
|
+
Mercur exposes a `getOrderGroupDetailWorkflow` that fetches the group, expands
|
|
11
|
+
its child orders, and derives each order's payment and fulfillment status. 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/order-group/[id]/route.ts"
|
|
17
|
+
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
|
18
|
+
import { getOrderGroupDetailWorkflow } from "@mercurjs/core/workflows"
|
|
19
|
+
|
|
20
|
+
export async function GET(req: MedusaRequest, res: MedusaResponse) {
|
|
21
|
+
const { result: order_group } = await getOrderGroupDetailWorkflow(
|
|
22
|
+
req.scope
|
|
23
|
+
).run({
|
|
24
|
+
input: {
|
|
25
|
+
order_group_id: req.params.id,
|
|
26
|
+
fields: ["id", "display_id", "total", "seller_count", "cart_id"],
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
res.json({ order_group })
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The workflow always expands the group's child orders regardless of the `fields`
|
|
35
|
+
you pass, so `order_group.orders` is populated with each seller's slice.
|
|
36
|
+
|
|
37
|
+
<Note>
|
|
38
|
+
The workflow only fetches heavy relations when you ask for them: include a
|
|
39
|
+
`payment_collections` field to get per-order `payment_status`, and a
|
|
40
|
+
`fulfillments` field to get `fulfillment_status`. Otherwise those collections
|
|
41
|
+
are stripped from the response to keep it lean.
|
|
42
|
+
</Note>
|
|
43
|
+
|
|
44
|
+
## Follow the cart link
|
|
45
|
+
|
|
46
|
+
The group's read-only `cart_id` points back to the immutable cart it came from.
|
|
47
|
+
Expand it through the module link when you need the original basket:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
await getOrderGroupDetailWorkflow(req.scope).run({
|
|
51
|
+
input: {
|
|
52
|
+
order_group_id: req.params.id,
|
|
53
|
+
fields: ["id", "cart.id", "cart.email", "orders.id", "orders.total"],
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
<Tip>
|
|
59
|
+
Prefer the workflow over reading the record directly. It does the child-order
|
|
60
|
+
status aggregation for you. The raw
|
|
61
|
+
[service method](/platform/order-group/reference/service) returns only the
|
|
62
|
+
group row and its computed totals.
|
|
63
|
+
</Tip>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Split a cart into orders"
|
|
3
|
+
sidebarTitle: "Split a cart"
|
|
4
|
+
description: "Complete a multi-seller cart into a group of per-seller orders with completeCartWithSplitOrdersWorkflow."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
In this guide, you'll learn how the checkout split works and how to run it from
|
|
8
|
+
your own server code, such as a custom complete-cart route.
|
|
9
|
+
|
|
10
|
+
Mercur replaces Medusa's single-order checkout with
|
|
11
|
+
`completeCartWithSplitOrdersWorkflow`. It takes a cart that may hold offers from
|
|
12
|
+
several sellers, creates one order per seller, and wraps them in an `OrderGroup`.
|
|
13
|
+
|
|
14
|
+
## Run the workflow
|
|
15
|
+
|
|
16
|
+
```ts title="src/api/store/carts/[id]/complete/route.ts"
|
|
17
|
+
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
|
18
|
+
import { completeCartWithSplitOrdersWorkflow } from "@mercurjs/core/workflows"
|
|
19
|
+
|
|
20
|
+
export async function POST(req: MedusaRequest, res: MedusaResponse) {
|
|
21
|
+
const { result } = await completeCartWithSplitOrdersWorkflow(req.scope).run({
|
|
22
|
+
input: { cart_id: req.params.id },
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
res.json({ order_group_id: result.order_group_id })
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The workflow is idempotent per cart: if a group already exists for the cart it
|
|
30
|
+
returns the existing `order_group_id` instead of splitting again. It acquires a
|
|
31
|
+
lock on the cart id for the duration of the split so concurrent completions can't
|
|
32
|
+
create duplicate orders.
|
|
33
|
+
|
|
34
|
+
<Note>
|
|
35
|
+
Line items are grouped by `item.offer.seller_id`. Sellers sell against the
|
|
36
|
+
shared master catalog through **offers**, so a line item's seller comes from
|
|
37
|
+
its offer, never from product ownership.
|
|
38
|
+
</Note>
|
|
39
|
+
|
|
40
|
+
## What happens during the split
|
|
41
|
+
|
|
42
|
+
For the cart, the workflow validates payments and per-seller shipping, then in a
|
|
43
|
+
single transaction:
|
|
44
|
+
|
|
45
|
+
- creates the parent `OrderGroup` (`customer_id`, `cart_id`)
|
|
46
|
+
- creates one child `Order` per seller from that seller's items and shipping
|
|
47
|
+
- links each order to the group, its seller, and the originating cart
|
|
48
|
+
- mirrors line-item → offer links, reserves offer inventory, and splits payment captures proportionally
|
|
49
|
+
- refreshes commission lines per order and marks the cart `completed_at`
|
|
50
|
+
|
|
51
|
+
Finally it emits `order.placed` for the created orders and `order_group.created`
|
|
52
|
+
for the group.
|
|
53
|
+
|
|
54
|
+
<Tip>
|
|
55
|
+
The workflow exposes hooks `validate`, `beforePaymentAuthorization`, and
|
|
56
|
+
`orderGroupCreated`, so you can inject marketplace-specific logic around the
|
|
57
|
+
split without forking it.
|
|
58
|
+
</Tip>
|