docs: fix complete cart workflow usage in marketplace recipe (#9771)
- Fix usage of `completeCartWorkflow` which now returns an ID instead of the full order - other: improvements in config across projects
This commit is contained in:
1 parent
853dd38044
commit
bf18d73ff4
5 files changed
+28
-18
No files matched your search
@@ -21,19 +21,15 @@ const withMDX = mdx({
|
|||||||
projectUrls: {
|
projectUrls: {
|
||||||
resources: {
|
resources: {
|
||||||
url: process.env.NEXT_PUBLIC_RESOURCES_URL,
|
url: process.env.NEXT_PUBLIC_RESOURCES_URL,
|
||||||
path: "resources",
|
|
||||||
},
|
},
|
||||||
"user-guide": {
|
"user-guide": {
|
||||||
url: process.env.NEXT_PUBLIC_RESOURCES_URL,
|
url: process.env.NEXT_PUBLIC_RESOURCES_URL,
|
||||||
path: "user-guide",
|
|
||||||
},
|
},
|
||||||
ui: {
|
ui: {
|
||||||
url: process.env.NEXT_PUBLIC_RESOURCES_URL,
|
url: process.env.NEXT_PUBLIC_RESOURCES_URL,
|
||||||
path: "ui",
|
|
||||||
},
|
},
|
||||||
api: {
|
api: {
|
||||||
url: process.env.NEXT_PUBLIC_RESOURCES_URL,
|
url: process.env.NEXT_PUBLIC_RESOURCES_URL,
|
||||||
path: "api",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
useBaseUrl:
|
useBaseUrl:
|
||||||
|
|||||||
@@ -791,15 +791,17 @@ In this step, you’ll create a workflow that’s executed when the customer pla
|
|||||||
graph TD
|
graph TD
|
||||||
retrieveCartStep["Retrieve Cart (useRemoteQueryStep from Medusa)"] --> completeCartWorkflow["completeCartWorkflow (Medusa)"]
|
retrieveCartStep["Retrieve Cart (useRemoteQueryStep from Medusa)"] --> completeCartWorkflow["completeCartWorkflow (Medusa)"]
|
||||||
completeCartWorkflow["completeCartWorkflow (Medusa)"] --> groupVendorItemsStep
|
completeCartWorkflow["completeCartWorkflow (Medusa)"] --> groupVendorItemsStep
|
||||||
groupVendorItemsStep --> createVendorOrdersStep
|
groupVendorItemsStep --> getOrderDetailWorkflow
|
||||||
|
getOrderDetailWorkflow --> createVendorOrdersStep
|
||||||
createVendorOrdersStep --> createRemoteLinkStep["Create Links (createRemoteLinkStep from Medusa)"]
|
createVendorOrdersStep --> createRemoteLinkStep["Create Links (createRemoteLinkStep from Medusa)"]
|
||||||
```
|
```
|
||||||
|
|
||||||
1. Retrieve the cart using its ID. Medusa provides a `useRemoteQueryStep` in the `@medusajs/medusa/core-flows` package that you can use.
|
1. Retrieve the cart using its ID. Medusa provides a `useRemoteQueryStep` in the `@medusajs/medusa/core-flows` package that you can use.
|
||||||
2. Create a parent order for the cart and its items. Medusa also has a `completeCartWorkflow` in the `@medusajs/medusa/core-flows` package that you can use as a step.
|
2. Create a parent order for the cart and its items. Medusa also has a `completeCartWorkflow` in the `@medusajs/medusa/core-flows` package that you can use as a step.
|
||||||
3. Group the cart items by their product’s associated vendor.
|
3. Group the cart items by their product’s associated vendor.
|
||||||
4. For each vendor, create a child order with the cart items of their products, and return the orders with the links to be created.
|
4. Retrieve the order's details using Medusa's `getOrderDetailWorkflow` exported by the `@medusajs/medusa/core-flows` package.
|
||||||
5. Create the links created by the previous step. Medusa provides a `createRemoteLinkStep` in the `@medusajs/medusa/core-flows` package that you can use.
|
5. For each vendor, create a child order with the cart items of their products, and return the orders with the links to be created.
|
||||||
|
6. Create the links created by the previous step. Medusa provides a `createRemoteLinkStep` in the `@medusajs/medusa/core-flows` package that you can use.
|
||||||
|
|
||||||
You'll implement the third and fourth steps.
|
You'll implement the third and fourth steps.
|
||||||
|
|
||||||
@@ -1135,6 +1137,7 @@ import {
|
|||||||
useRemoteQueryStep,
|
useRemoteQueryStep,
|
||||||
createRemoteLinkStep,
|
createRemoteLinkStep,
|
||||||
completeCartWorkflow,
|
completeCartWorkflow,
|
||||||
|
getOrderDetailWorkflow
|
||||||
} from "@medusajs/medusa/core-flows"
|
} from "@medusajs/medusa/core-flows"
|
||||||
import { CartDTO } from "@medusajs/framework/types"
|
import { CartDTO } from "@medusajs/framework/types"
|
||||||
import groupVendorItemsStep from "./steps/group-vendor-items"
|
import groupVendorItemsStep from "./steps/group-vendor-items"
|
||||||
@@ -1155,16 +1158,32 @@ const createVendorOrdersWorkflow = createWorkflow(
|
|||||||
throw_if_key_not_found: true,
|
throw_if_key_not_found: true,
|
||||||
}) as CartDTO
|
}) as CartDTO
|
||||||
|
|
||||||
const order = completeCartWorkflow.runAsStep({
|
const { id: orderId } = completeCartWorkflow.runAsStep({
|
||||||
input: {
|
input: {
|
||||||
id: cart.id,
|
id: cart.id
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const { vendorsItems } = groupVendorItemsStep({
|
const { vendorsItems } = groupVendorItemsStep({
|
||||||
cart,
|
cart,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const order = getOrderDetailWorkflow.runAsStep({
|
||||||
|
input: {
|
||||||
|
order_id: orderId,
|
||||||
|
fields: [
|
||||||
|
"region_id",
|
||||||
|
"customer_id",
|
||||||
|
"sales_channel_id",
|
||||||
|
"email",
|
||||||
|
"currency_code",
|
||||||
|
"shipping_address.*",
|
||||||
|
"billing_address.*",
|
||||||
|
"shipping_methods.*",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const {
|
const {
|
||||||
orders: vendorOrders,
|
orders: vendorOrders,
|
||||||
linkDefs,
|
linkDefs,
|
||||||
|
|||||||
@@ -19,19 +19,16 @@ const mdxPluginOptions = {
|
|||||||
projectUrls: {
|
projectUrls: {
|
||||||
docs: {
|
docs: {
|
||||||
url: process.env.NEXT_PUBLIC_DOCS_URL,
|
url: process.env.NEXT_PUBLIC_DOCS_URL,
|
||||||
path: "v2",
|
path: "",
|
||||||
},
|
},
|
||||||
"user-guide": {
|
"user-guide": {
|
||||||
url: process.env.NEXT_PUBLIC_USER_GUIDE_URL,
|
url: process.env.NEXT_PUBLIC_USER_GUIDE_URL,
|
||||||
path: "v2/user-guide",
|
|
||||||
},
|
},
|
||||||
ui: {
|
ui: {
|
||||||
url: process.env.NEXT_PUBLIC_UI_URL,
|
url: process.env.NEXT_PUBLIC_UI_URL,
|
||||||
path: "ui",
|
|
||||||
},
|
},
|
||||||
api: {
|
api: {
|
||||||
url: process.env.NEXT_PUBLIC_API_URL,
|
url: process.env.NEXT_PUBLIC_API_URL,
|
||||||
path: "v2/api",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
useBaseUrl:
|
useBaseUrl:
|
||||||
|
|||||||
@@ -23,18 +23,16 @@ const withMDX = mdx({
|
|||||||
projectUrls: {
|
projectUrls: {
|
||||||
docs: {
|
docs: {
|
||||||
url: process.env.NEXT_PUBLIC_DOCS_URL,
|
url: process.env.NEXT_PUBLIC_DOCS_URL,
|
||||||
|
path: "",
|
||||||
},
|
},
|
||||||
resources: {
|
resources: {
|
||||||
url: process.env.NEXT_PUBLIC_RESOURCES_URL,
|
url: process.env.NEXT_PUBLIC_RESOURCES_URL,
|
||||||
path: "resources",
|
|
||||||
},
|
},
|
||||||
ui: {
|
ui: {
|
||||||
url: process.env.NEXT_PUBLIC_UI_URL,
|
url: process.env.NEXT_PUBLIC_UI_URL,
|
||||||
path: "ui",
|
|
||||||
},
|
},
|
||||||
api: {
|
api: {
|
||||||
url: process.env.NEXT_PUBLIC_API_URL,
|
url: process.env.NEXT_PUBLIC_API_URL,
|
||||||
path: "api",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
useBaseUrl:
|
useBaseUrl:
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ function matchAndFixLinks(
|
|||||||
const path =
|
const path =
|
||||||
projectUrls &&
|
projectUrls &&
|
||||||
Object.hasOwn(projectUrls, projectArea.groups.area) &&
|
Object.hasOwn(projectUrls, projectArea.groups.area) &&
|
||||||
projectUrls[projectArea.groups.area]?.path
|
projectUrls[projectArea.groups.area]?.path !== undefined
|
||||||
? projectUrls[projectArea.groups.area].path
|
? projectUrls[projectArea.groups.area].path
|
||||||
: projectArea.groups.area
|
: projectArea.groups.area
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user