chore: generate core-flows reference for 2.3.0 (#11028)
This commit is contained in:
1 parent
e50d0ff369
commit
bff8c0bc93
1055 files changed
+289674
-279277
No files matched your search
+12
-17
@@ -14,28 +14,23 @@ This documentation provides a reference to the `createApiKeysStep`. It belongs t
|
||||
|
||||
This step creates one or more API keys.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { createApiKeysStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = createApiKeysStep({
|
||||
"api_keys": [{
|
||||
"title": "derideo",
|
||||
"type": "secret",
|
||||
"created_by": "user_NaVGVsHtBHlMwdJ"
|
||||
}]
|
||||
})
|
||||
}
|
||||
)
|
||||
```ts
|
||||
const data = createApiKeysStep({
|
||||
api_keys: [
|
||||
{
|
||||
type: "publishable",
|
||||
title: "Storefront",
|
||||
created_by: "user_123"
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"CreateApiKeysStepInput","type":"[CreateApiKeysStepInput](../../../../types/core_flows.CreateApiKeysStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"api_keys","type":"[CreateApiKeyDTO](../../../../../api_key/interfaces/api_key.CreateApiKeyDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApiKeyType](../../../../../api_key/types/api_key.ApiKeyType/page.mdx)","description":"The type of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`string`","description":"Who created the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createApiKeysStep"/>
|
||||
<TypeList types={[{"name":"CreateApiKeysStepInput","type":"[CreateApiKeysStepInput](../../../../types/core_flows.CreateApiKeysStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"api_keys","type":"[CreateApiKeyDTO](../../../../../api_key/interfaces/api_key.CreateApiKeyDTO/page.mdx)[]","description":"The API keys to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApiKeyType](../../../../../api_key/types/api_key.ApiKeyType/page.mdx)","description":"The type of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`string`","description":"Who created the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createApiKeysStep"/>
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+2
-4
@@ -21,9 +21,7 @@ import { deleteApiKeysStep } from "@medusajs/medusa/core-flows"
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = deleteApiKeysStep([
|
||||
"{value}"
|
||||
])
|
||||
const data = deleteApiKeysStep({})
|
||||
}
|
||||
)
|
||||
```
|
||||
@@ -31,4 +29,4 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"string[]","type":"`string`[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"string","type":"`string`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="deleteApiKeysStep"/>
|
||||
<TypeList types={[{"name":"DeleteApiKeysStepInput","type":"[DeleteApiKeysStepInput](../../../../types/core_flows.DeleteApiKeysStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"DeleteApiKeysStepInput","type":"`string`[]","description":"The IDs of the API keys to delete.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="deleteApiKeysStep"/>
|
||||
+8
-13
@@ -12,22 +12,17 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `linkSalesChannelsToApiKeyStep`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This step links sales channels to API keys.
|
||||
This step manages the sales channels of a publishable API key.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { linkSalesChannelsToApiKeyStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = linkSalesChannelsToApiKeyStep({
|
||||
"id": "id_vb6fZX5fJAEOWY"
|
||||
})
|
||||
}
|
||||
)
|
||||
```ts
|
||||
const data = linkSalesChannelsToApiKeyStep({
|
||||
id: "apk_123",
|
||||
add: ["sc_123"],
|
||||
remove: ["sc_456"]
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
|
||||
+10
-15
@@ -14,27 +14,22 @@ This documentation provides a reference to the `revokeApiKeysStep`. It belongs t
|
||||
|
||||
This step revokes one or more API keys.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { revokeApiKeysStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = revokeApiKeysStep({
|
||||
"selector": {},
|
||||
"revoke": {
|
||||
"revoked_by": "{value}"
|
||||
}
|
||||
})
|
||||
```ts
|
||||
const data = revokeApiKeysStep({
|
||||
selector: {
|
||||
id: "apk_123"
|
||||
},
|
||||
revoke: {
|
||||
revoked_by: "user_123"
|
||||
}
|
||||
)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"RevokeApiKeysStepInput","type":"[RevokeApiKeysStepInput](../../../../types/core_flows.RevokeApiKeysStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"selector","type":"[FilterableApiKeyProps](../../../../../api_key/interfaces/api_key.FilterableApiKeyProps/page.mdx)","description":"The filters to apply on the retrieved API keys.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Search through the api key names and redacted keys using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"The IDs to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"token","type":"`string` \\| `string`[]","description":"The tokens to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string` \\| `string`[]","description":"The titles to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApiKeyType](../../../../../api_key/types/api_key.ApiKeyType/page.mdx)","description":"Filter the API keys by their type.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"revoked_at","type":"[OperatorMap](../../../../../api_key/types/api_key.OperatorMap/page.mdx)<null \\| Date>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"$and","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$or","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$eq","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T> \\| [ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ne","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$in","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$nin","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$not","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>","description":"API wrapper around the remoteQuery","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gt","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gte","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lt","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lte","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$like","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$re","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ilike","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$fulltext","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$overlap","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contains","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contained","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$exists","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"$and","type":"([FilterableApiKeyProps](../../../../../api_key/interfaces/api_key.FilterableApiKeyProps/page.mdx) \\| [BaseFilterable](../../../../../api_key/interfaces/api_key.BLine truncated
|
||||
<TypeList types={[{"name":"RevokeApiKeysStepInput","type":"[RevokeApiKeysStepInput](../../../../types/core_flows.RevokeApiKeysStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"selector","type":"[FilterableApiKeyProps](../../../../../api_key/interfaces/api_key.FilterableApiKeyProps/page.mdx)","description":"The filters to select the API keys to revoke.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Search through the api key names and redacted keys using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"The IDs to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"token","type":"`string` \\| `string`[]","description":"The tokens to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string` \\| `string`[]","description":"The titles to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApiKeyType](../../../../../api_key/types/api_key.ApiKeyType/page.mdx)","description":"Filter the API keys by their type.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"revoked_at","type":"[OperatorMap](../../../../../api_key/types/api_key.OperatorMap/page.mdx)<null \\| Date>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"$and","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$or","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$eq","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T> \\| [ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ne","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$in","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$nin","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$not","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>","description":"API wrapper around the remoteQuery","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gt","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gte","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lt","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lte","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$like","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$re","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ilike","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$fulltext","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$overlap","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contains","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contained","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$exists","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"$and","type":"([FilterableApiKeyProps](../../../../../api_key/interfaces/api_key.FilterableApiKeyProps/page.mdx) \\| [BaseFilterable](../../../../../api_key/interfaces/api_key.BasLine truncated
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+10
-13
@@ -14,25 +14,22 @@ This documentation provides a reference to the `updateApiKeysStep`. It belongs t
|
||||
|
||||
This step updates one or more API keys.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { updateApiKeysStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = updateApiKeysStep({
|
||||
"selector": {},
|
||||
"update": {}
|
||||
})
|
||||
```ts
|
||||
const data = updateApiKeysStep({
|
||||
selector: {
|
||||
id: "apk_123"
|
||||
},
|
||||
update: {
|
||||
title: "Storefront"
|
||||
}
|
||||
)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"UpdateApiKeysStepInput","type":"[UpdateApiKeysStepInput](../../../../types/core_flows.UpdateApiKeysStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"selector","type":"[FilterableApiKeyProps](../../../../../api_key/interfaces/api_key.FilterableApiKeyProps/page.mdx)","description":"The filters to apply on the retrieved API keys.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Search through the api key names and redacted keys using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"The IDs to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"token","type":"`string` \\| `string`[]","description":"The tokens to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string` \\| `string`[]","description":"The titles to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApiKeyType](../../../../../api_key/types/api_key.ApiKeyType/page.mdx)","description":"Filter the API keys by their type.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"revoked_at","type":"[OperatorMap](../../../../../api_key/types/api_key.OperatorMap/page.mdx)<null \\| Date>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"$and","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$or","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$eq","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T> \\| [ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ne","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$in","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$nin","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$not","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>","description":"API wrapper around the remoteQuery","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gt","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gte","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lt","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lte","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$like","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$re","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ilike","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$fulltext","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$overlap","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contains","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contained","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$exists","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"$and","type":"([FilterableApiKeyProps](../../../../../api_key/interfaces/api_key.FilterableApiKeyProps/page.mdx) \\| [BaseFilterable](../../../../../api_key/interfaces/api_key.BLine truncated
|
||||
<TypeList types={[{"name":"UpdateApiKeysStepInput","type":"[UpdateApiKeysStepInput](../../../../types/core_flows.UpdateApiKeysStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"selector","type":"[FilterableApiKeyProps](../../../../../api_key/interfaces/api_key.FilterableApiKeyProps/page.mdx)","description":"The filters to select the API keys to update.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Search through the api key names and redacted keys using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"The IDs to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"token","type":"`string` \\| `string`[]","description":"The tokens to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string` \\| `string`[]","description":"The titles to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApiKeyType](../../../../../api_key/types/api_key.ApiKeyType/page.mdx)","description":"Filter the API keys by their type.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"revoked_at","type":"[OperatorMap](../../../../../api_key/types/api_key.OperatorMap/page.mdx)<null \\| Date>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"$and","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$or","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$eq","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T> \\| [ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ne","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$in","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$nin","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$not","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>","description":"API wrapper around the remoteQuery","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gt","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gte","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lt","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lte","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$like","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$re","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ilike","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$fulltext","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$overlap","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contains","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contained","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$exists","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"$and","type":"([FilterableApiKeyProps](../../../../../api_key/interfaces/api_key.FilterableApiKeyProps/page.mdx) \\| [BaseFilterable](../../../../../api_key/interfaces/api_key.BasLine truncated
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+2
-1
@@ -13,6 +13,7 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
This documentation provides a reference to the `validateSalesChannelsExistStep`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This step validates that a sales channel exists before linking it to an API key.
|
||||
If the sales channel does not exist, the step throws an error.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
@@ -33,7 +34,7 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"ValidateSalesChannelsExistStepInput","type":"[ValidateSalesChannelsExistStepInput](../../../../interfaces/core_flows.ValidateSalesChannelsExistStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"sales_channel_ids","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validateSalesChannelsExistStep"/>
|
||||
<TypeList types={[{"name":"ValidateSalesChannelsExistStepInput","type":"[ValidateSalesChannelsExistStepInput](../../../../interfaces/core_flows.ValidateSalesChannelsExistStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"sales_channel_ids","type":"`string`[]","description":"The IDs of the sales channels to validate.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validateSalesChannelsExistStep"/>
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+25
-21
@@ -12,9 +12,13 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `createApiKeysWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow creates one or more API keys.
|
||||
This workflow creates one or more API keys, which can be secret or publishable. It's used by the
|
||||
[Create API Key Admin API Route](https://docs.medusajs.com/api/admin#api-keys\_postapikeys).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/api-key/workflows/create-api-keys.ts#L15" />
|
||||
You can use this workflow within your customizations or your own custom workflows, allowing you to
|
||||
create API keys within your custom flows.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/api-key/workflows/create-api-keys.ts#L50" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -35,10 +39,10 @@ export async function POST(
|
||||
const { result } = await createApiKeysWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"api_keys": [{
|
||||
"title": "suscipio",
|
||||
"type": "publishable",
|
||||
"created_by": "user_svZrl7Ubex"
|
||||
api_keys: [{
|
||||
type: "publishable",
|
||||
title: "Storefront",
|
||||
created_by: "user_123"
|
||||
}]
|
||||
}
|
||||
})
|
||||
@@ -64,10 +68,10 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await createApiKeysWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"api_keys": [{
|
||||
"title": "suscipio",
|
||||
"type": "publishable",
|
||||
"created_by": "user_svZrl7Ubex"
|
||||
api_keys: [{
|
||||
type: "publishable",
|
||||
title: "Storefront",
|
||||
created_by: "user_123"
|
||||
}]
|
||||
}
|
||||
})
|
||||
@@ -93,10 +97,10 @@ export default async function myCustomJob(
|
||||
const { result } = await createApiKeysWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"api_keys": [{
|
||||
"title": "suscipio",
|
||||
"type": "publishable",
|
||||
"created_by": "user_svZrl7Ubex"
|
||||
api_keys: [{
|
||||
type: "publishable",
|
||||
title: "Storefront",
|
||||
created_by: "user_123"
|
||||
}]
|
||||
}
|
||||
})
|
||||
@@ -123,10 +127,10 @@ const myWorkflow = createWorkflow(
|
||||
const result = createApiKeysWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"api_keys": [{
|
||||
"title": "suscipio",
|
||||
"type": "publishable",
|
||||
"created_by": "user_svZrl7Ubex"
|
||||
api_keys: [{
|
||||
type: "publishable",
|
||||
title: "Storefront",
|
||||
created_by: "user_123"
|
||||
}]
|
||||
}
|
||||
})
|
||||
@@ -139,12 +143,12 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"createApiKeysWorkflow","steps":[{"type":"step","name":"createApiKeysStep","description":"This step creates one or more API keys.\n\n","link":"../../../Steps_Api_Key/functions/core_flows.Api_Key.Steps_Api_Key.createApiKeysStep/page.mdx","depth":1}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"createApiKeysWorkflow","steps":[{"type":"step","name":"createApiKeysStep","description":"This step creates one or more API keys.","link":"../../../Steps_Api_Key/functions/core_flows.Api_Key.Steps_Api_Key.createApiKeysStep/page.mdx","depth":1}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"CreateApiKeysWorkflowInput","type":"[CreateApiKeysWorkflowInput](../../../../types/core_flows.CreateApiKeysWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"api_keys","type":"[CreateApiKeyDTO](../../../../../api_key/interfaces/api_key.CreateApiKeyDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApiKeyType](../../../../../api_key/types/api_key.ApiKeyType/page.mdx)","description":"The type of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`string`","description":"Who created the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createApiKeysWorkflow"/>
|
||||
<TypeList types={[{"name":"CreateApiKeysWorkflowInput","type":"[CreateApiKeysWorkflowInput](../../../../types/core_flows.CreateApiKeysWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"The data to create API keys.","expandable":false,"children":[{"name":"api_keys","type":"[CreateApiKeyDTO](../../../../../api_key/interfaces/api_key.CreateApiKeyDTO/page.mdx)[]","description":"The API keys to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApiKeyType](../../../../../api_key/types/api_key.ApiKeyType/page.mdx)","description":"The type of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`string`","description":"Who created the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createApiKeysWorkflow"/>
|
||||
|
||||
## Output
|
||||
|
||||
<TypeList types={[{"name":"ApiKeyDTO[]","type":"[ApiKeyDTO](../../../../../api_key/interfaces/api_key.ApiKeyDTO/page.mdx)[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"ApiKeyDTO","type":"[ApiKeyDTO](../../../../../api_key/interfaces/api_key.ApiKeyDTO/page.mdx)","optional":false,"defaultValue":"","description":"The API key details.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"token","type":"`string`","description":"The token of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"redacted","type":"`string`","description":"The redacted form of the API key's token. This is useful\nwhen showing portion of the token. For example `sk_...123`.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApiKeyType](../../../../../api_key/types/api_key.ApiKeyType/page.mdx)","description":"The type of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"last_used_at","type":"`null` \\| `Date`","description":"The date the API key was last used.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`string`","description":"Who created the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The date the API key was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The date the API key was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The date the API key was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"revoked_by","type":"`null` \\| `string`","description":"Who revoked the API key. For example,\nthe ID of the user that revoked it.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"revoked_at","type":"`null` \\| `Date`","description":"The date the API key was revoked.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createApiKeysWorkflow"/>
|
||||
<TypeList types={[{"name":"CreateApiKeysWorkflowOutput","type":"[CreateApiKeysWorkflowOutput](../../../../types/core_flows.CreateApiKeysWorkflowOutput/page.mdx)","optional":false,"defaultValue":"","description":"The created API keys.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"token","type":"`string`","description":"The token of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"redacted","type":"`string`","description":"The redacted form of the API key's token. This is useful\nwhen showing portion of the token. For example `sk_...123`.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApiKeyType](../../../../../api_key/types/api_key.ApiKeyType/page.mdx)","description":"The type of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"last_used_at","type":"`null` \\| `Date`","description":"The date the API key was last used.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`string`","description":"Who created the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The date the API key was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The date the API key was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The date the API key was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"revoked_by","type":"`null` \\| `string`","description":"Who revoked the API key. For example,\nthe ID of the user that revoked it.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"revoked_at","type":"`null` \\| `Date`","description":"The date the API key was revoked.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createApiKeysWorkflow"/>
|
||||
+12
-16
@@ -13,9 +13,13 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `deleteApiKeysWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow deletes one or more API keys.
|
||||
This workflow deletes one or more secret or publishable API keys. It's used by the
|
||||
[Delete API Key Admin API Route](https://docs.medusajs.com/api/admin#api-keys\_deleteapikeysid).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/api-key/workflows/delete-api-keys.ts#L12" />
|
||||
You can use this workflow within your customizations or your own custom workflows, allowing you to
|
||||
delete API keys within your custom flows.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/api-key/workflows/delete-api-keys.ts#L36" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -36,9 +40,7 @@ export async function POST(
|
||||
const { result } = await deleteApiKeysWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"ids": [
|
||||
"id_iMZLYsRAs2bbPci"
|
||||
]
|
||||
ids: ["apk_123"]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -63,9 +65,7 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await deleteApiKeysWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"ids": [
|
||||
"id_iMZLYsRAs2bbPci"
|
||||
]
|
||||
ids: ["apk_123"]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -90,9 +90,7 @@ export default async function myCustomJob(
|
||||
const { result } = await deleteApiKeysWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"ids": [
|
||||
"id_iMZLYsRAs2bbPci"
|
||||
]
|
||||
ids: ["apk_123"]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -118,9 +116,7 @@ const myWorkflow = createWorkflow(
|
||||
const result = deleteApiKeysWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"ids": [
|
||||
"id_iMZLYsRAs2bbPci"
|
||||
]
|
||||
ids: ["apk_123"]
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -132,8 +128,8 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"deleteApiKeysWorkflow","steps":[{"type":"step","name":"deleteApiKeysStep","description":"This step deletes one or more API keys.\n\n","link":"../../../Steps_Api_Key/functions/core_flows.Api_Key.Steps_Api_Key.deleteApiKeysStep/page.mdx","depth":1},{"type":"step","name":"removeRemoteLinkStep","description":"This step deletes linked records of a record.\n\nLearn more in the [Remote Link documentation](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#cascade-delete-linked-records)\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.removeRemoteLinkStep/page.mdx","depth":2}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"deleteApiKeysWorkflow","steps":[{"type":"step","name":"deleteApiKeysStep","description":"This step deletes one or more API keys.","link":"../../../Steps_Api_Key/functions/core_flows.Api_Key.Steps_Api_Key.deleteApiKeysStep/page.mdx","depth":1},{"type":"step","name":"removeRemoteLinkStep","description":"This step deletes linked records of a record.\n\nLearn more in the [Remote Link documentation](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#cascade-delete-linked-records)","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.removeRemoteLinkStep/page.mdx","depth":2}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"DeleteApiKeysWorkflowInput","type":"[DeleteApiKeysWorkflowInput](../../../../types/core_flows.DeleteApiKeysWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"ids","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="deleteApiKeysWorkflow"/>
|
||||
<TypeList types={[{"name":"DeleteApiKeysWorkflowInput","type":"[DeleteApiKeysWorkflowInput](../../../../types/core_flows.DeleteApiKeysWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"The data to delete API keys.","expandable":false,"children":[{"name":"ids","type":"`string`[]","description":"The IDs of the API keys to delete.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="deleteApiKeysWorkflow"/>
|
||||
+19
-7
@@ -13,9 +13,13 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `linkSalesChannelsToApiKeyWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow links sales channels to API keys.
|
||||
This workflow manages the sales channels of a publishable API key. It's used by the
|
||||
[Manage Sales Channels API Route](https://docs.medusajs.com/api/admin#api-keys\_postapikeysidsaleschannels).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/api-key/workflows/link-sales-channels-to-publishable-key.ts#L13" />
|
||||
You can use this workflow within your customizations or your own custom workflows, allowing you to
|
||||
manage the sales channels of a publishable API key within your custom flows.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/api-key/workflows/link-sales-channels-to-publishable-key.ts#L36" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -36,7 +40,9 @@ export async function POST(
|
||||
const { result } = await linkSalesChannelsToApiKeyWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"id": "id_ho4tqCcF0SooZ"
|
||||
id: "apk_132",
|
||||
add: ["sc_123"],
|
||||
remove: ["sc_321"]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -61,7 +67,9 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await linkSalesChannelsToApiKeyWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"id": "id_ho4tqCcF0SooZ"
|
||||
id: "apk_132",
|
||||
add: ["sc_123"],
|
||||
remove: ["sc_321"]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -86,7 +94,9 @@ export default async function myCustomJob(
|
||||
const { result } = await linkSalesChannelsToApiKeyWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"id": "id_ho4tqCcF0SooZ"
|
||||
id: "apk_132",
|
||||
add: ["sc_123"],
|
||||
remove: ["sc_321"]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -112,7 +122,9 @@ const myWorkflow = createWorkflow(
|
||||
const result = linkSalesChannelsToApiKeyWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"id": "id_ho4tqCcF0SooZ"
|
||||
id: "apk_132",
|
||||
add: ["sc_123"],
|
||||
remove: ["sc_321"]
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -124,7 +136,7 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"linkSalesChannelsToApiKeyWorkflow","steps":[{"type":"step","name":"validateSalesChannelsExistStep","description":"This step validates that a sales channel exists before linking it to an API key.\n\n","link":"../../../Steps_Api_Key/functions/core_flows.Api_Key.Steps_Api_Key.validateSalesChannelsExistStep/page.mdx","depth":1},{"type":"step","name":"linkSalesChannelsToApiKeyStep","description":"This step links sales channels to API keys.\n\n","link":"../../../Steps_Api_Key/functions/core_flows.Api_Key.Steps_Api_Key.linkSalesChannelsToApiKeyStep/page.mdx","depth":2}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"linkSalesChannelsToApiKeyWorkflow","steps":[{"type":"step","name":"validateSalesChannelsExistStep","description":"This step validates that a sales channel exists before linking it to an API key.\nIf the sales channel does not exist, the step throws an error.","link":"../../../Steps_Api_Key/functions/core_flows.Api_Key.Steps_Api_Key.validateSalesChannelsExistStep/page.mdx","depth":1},{"type":"step","name":"linkSalesChannelsToApiKeyStep","description":"This step manages the sales channels of a publishable API key.","link":"../../../Steps_Api_Key/functions/core_flows.Api_Key.Steps_Api_Key.linkSalesChannelsToApiKeyStep/page.mdx","depth":2}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
|
||||
+31
-17
@@ -12,9 +12,15 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `revokeApiKeysWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow revokes one or more API keys.
|
||||
This workflow revokes one or more API keys. If the API key is a secret,
|
||||
it can't be used for authentication anymore. If it's publishable, it can't be used by client applications.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/api-key/workflows/revoke-api-keys.ts#L22" />
|
||||
This workflow is used by the [Revoke API Key API Route](https://docs.medusajs.com/api/admin#api-keys\_postapikeysidrevoke).
|
||||
|
||||
You can use this workflow within your customizations or your own custom workflows, allowing you to
|
||||
revoke API keys within your custom flows.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/api-key/workflows/revoke-api-keys.ts#L59" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -35,9 +41,11 @@ export async function POST(
|
||||
const { result } = await revokeApiKeysWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"selector": {},
|
||||
"revoke": {
|
||||
"revoked_by": "{value}"
|
||||
selector: {
|
||||
id: "apk_123"
|
||||
},
|
||||
revoke: {
|
||||
revoked_by: "user_123"
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -63,9 +71,11 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await revokeApiKeysWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"selector": {},
|
||||
"revoke": {
|
||||
"revoked_by": "{value}"
|
||||
selector: {
|
||||
id: "apk_123"
|
||||
},
|
||||
revoke: {
|
||||
revoked_by: "user_123"
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -91,9 +101,11 @@ export default async function myCustomJob(
|
||||
const { result } = await revokeApiKeysWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"selector": {},
|
||||
"revoke": {
|
||||
"revoked_by": "{value}"
|
||||
selector: {
|
||||
id: "apk_123"
|
||||
},
|
||||
revoke: {
|
||||
revoked_by: "user_123"
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -120,9 +132,11 @@ const myWorkflow = createWorkflow(
|
||||
const result = revokeApiKeysWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"selector": {},
|
||||
"revoke": {
|
||||
"revoked_by": "{value}"
|
||||
selector: {
|
||||
id: "apk_123"
|
||||
},
|
||||
revoke: {
|
||||
revoked_by: "user_123"
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -135,12 +149,12 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"revokeApiKeysWorkflow","steps":[{"type":"step","name":"revokeApiKeysStep","description":"This step revokes one or more API keys.\n\n","link":"../../../Steps_Api_Key/functions/core_flows.Api_Key.Steps_Api_Key.revokeApiKeysStep/page.mdx","depth":1}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"revokeApiKeysWorkflow","steps":[{"type":"step","name":"revokeApiKeysStep","description":"This step revokes one or more API keys.","link":"../../../Steps_Api_Key/functions/core_flows.Api_Key.Steps_Api_Key.revokeApiKeysStep/page.mdx","depth":1}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"RevokeApiKeysWorkflowInput","type":"[RevokeApiKeysWorkflowInput](../../../../types/core_flows.RevokeApiKeysWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"selector","type":"[FilterableApiKeyProps](../../../../../api_key/interfaces/api_key.FilterableApiKeyProps/page.mdx)","description":"The filters to apply on the retrieved API keys.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Search through the api key names and redacted keys using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"The IDs to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"token","type":"`string` \\| `string`[]","description":"The tokens to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string` \\| `string`[]","description":"The titles to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApiKeyType](../../../../../api_key/types/api_key.ApiKeyType/page.mdx)","description":"Filter the API keys by their type.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"revoked_at","type":"[OperatorMap](../../../../../api_key/types/api_key.OperatorMap/page.mdx)<null \\| Date>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"$and","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$or","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$eq","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T> \\| [ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ne","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$in","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$nin","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$not","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>","description":"API wrapper around the remoteQuery","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gt","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gte","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lt","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lte","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$like","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$re","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ilike","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$fulltext","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$overlap","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contains","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contained","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$exists","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"$and","type":"([FilterableApiKeyProps](../../../../../api_key/interfaces/api_key.FilterableApiKeyProps/page.mdx) \\| [BaseFilterable](../../../../../api_key/interfacLine truncated
|
||||
<TypeList types={[{"name":"RevokeApiKeysWorkflowInput","type":"[RevokeApiKeysWorkflowInput](../../../../types/core_flows.RevokeApiKeysWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"The data to revoke API keys.","expandable":false,"children":[{"name":"selector","type":"[FilterableApiKeyProps](../../../../../api_key/interfaces/api_key.FilterableApiKeyProps/page.mdx)","description":"The filters to select the API keys to revoke.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Search through the api key names and redacted keys using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"The IDs to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"token","type":"`string` \\| `string`[]","description":"The tokens to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string` \\| `string`[]","description":"The titles to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApiKeyType](../../../../../api_key/types/api_key.ApiKeyType/page.mdx)","description":"Filter the API keys by their type.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"revoked_at","type":"[OperatorMap](../../../../../api_key/types/api_key.OperatorMap/page.mdx)<null \\| Date>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"$and","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$or","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$eq","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T> \\| [ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ne","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$in","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$nin","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$not","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>","description":"API wrapper around the remoteQuery","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gt","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gte","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lt","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lte","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$like","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$re","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ilike","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$fulltext","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$overlap","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contains","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contained","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$exists","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"$and","type":"([FilterableApiKeyProps](../../../../../api_key/interfaces/api_key.FilterableApiKeyProps/page.mdx) \\| [BaseFilterable](../..Line truncated
|
||||
|
||||
## Output
|
||||
|
||||
<TypeList types={[{"name":"ApiKeyDTO[]","type":"[ApiKeyDTO](../../../../../api_key/interfaces/api_key.ApiKeyDTO/page.mdx)[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"ApiKeyDTO","type":"[ApiKeyDTO](../../../../../api_key/interfaces/api_key.ApiKeyDTO/page.mdx)","optional":false,"defaultValue":"","description":"The API key details.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"token","type":"`string`","description":"The token of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"redacted","type":"`string`","description":"The redacted form of the API key's token. This is useful\nwhen showing portion of the token. For example `sk_...123`.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApiKeyType](../../../../../api_key/types/api_key.ApiKeyType/page.mdx)","description":"The type of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"last_used_at","type":"`null` \\| `Date`","description":"The date the API key was last used.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`string`","description":"Who created the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The date the API key was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The date the API key was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The date the API key was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"revoked_by","type":"`null` \\| `string`","description":"Who revoked the API key. For example,\nthe ID of the user that revoked it.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"revoked_at","type":"`null` \\| `Date`","description":"The date the API key was revoked.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="revokeApiKeysWorkflow"/>
|
||||
<TypeList types={[{"name":"RevokeApiKeysWorkflowOutput","type":"[RevokeApiKeysWorkflowOutput](../../../../types/core_flows.RevokeApiKeysWorkflowOutput/page.mdx)","optional":false,"defaultValue":"","description":"The revoked API keys.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"token","type":"`string`","description":"The token of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"redacted","type":"`string`","description":"The redacted form of the API key's token. This is useful\nwhen showing portion of the token. For example `sk_...123`.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApiKeyType](../../../../../api_key/types/api_key.ApiKeyType/page.mdx)","description":"The type of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"last_used_at","type":"`null` \\| `Date`","description":"The date the API key was last used.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`string`","description":"Who created the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The date the API key was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The date the API key was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The date the API key was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"revoked_by","type":"`null` \\| `string`","description":"Who revoked the API key. For example,\nthe ID of the user that revoked it.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"revoked_at","type":"`null` \\| `Date`","description":"The date the API key was revoked.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="revokeApiKeysWorkflow"/>
|
||||
+33
-13
@@ -12,9 +12,13 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `updateApiKeysWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow creates one or more API keys.
|
||||
This workflow updates one or more secret or publishable API keys. It's used by the
|
||||
[Update API Key Admin API Route](https://docs.medusajs.com/api/admin#api-keys\_postapikeysid).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/api-key/workflows/update-api-keys.ts#L22" />
|
||||
You can use this workflow within your customizations or your own custom workflows, allowing you to
|
||||
update API keys within your custom flows.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/api-key/workflows/update-api-keys.ts#L57" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -35,8 +39,12 @@ export async function POST(
|
||||
const { result } = await updateApiKeysWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"selector": {},
|
||||
"update": {}
|
||||
selector: {
|
||||
id: "apk_123"
|
||||
},
|
||||
update: {
|
||||
title: "Storefront"
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -61,8 +69,12 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await updateApiKeysWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"selector": {},
|
||||
"update": {}
|
||||
selector: {
|
||||
id: "apk_123"
|
||||
},
|
||||
update: {
|
||||
title: "Storefront"
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -87,8 +99,12 @@ export default async function myCustomJob(
|
||||
const { result } = await updateApiKeysWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"selector": {},
|
||||
"update": {}
|
||||
selector: {
|
||||
id: "apk_123"
|
||||
},
|
||||
update: {
|
||||
title: "Storefront"
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -114,8 +130,12 @@ const myWorkflow = createWorkflow(
|
||||
const result = updateApiKeysWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"selector": {},
|
||||
"update": {}
|
||||
selector: {
|
||||
id: "apk_123"
|
||||
},
|
||||
update: {
|
||||
title: "Storefront"
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -127,12 +147,12 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"updateApiKeysWorkflow","steps":[{"type":"step","name":"updateApiKeysStep","description":"This step updates one or more API keys.\n\n","link":"../../../Steps_Api_Key/functions/core_flows.Api_Key.Steps_Api_Key.updateApiKeysStep/page.mdx","depth":1}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"updateApiKeysWorkflow","steps":[{"type":"step","name":"updateApiKeysStep","description":"This step updates one or more API keys.","link":"../../../Steps_Api_Key/functions/core_flows.Api_Key.Steps_Api_Key.updateApiKeysStep/page.mdx","depth":1}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"UpdateApiKeysWorkflowInput","type":"[UpdateApiKeysWorkflowInput](../../../../types/core_flows.UpdateApiKeysWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"selector","type":"[FilterableApiKeyProps](../../../../../api_key/interfaces/api_key.FilterableApiKeyProps/page.mdx)","description":"The filters to apply on the retrieved API keys.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Search through the api key names and redacted keys using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"The IDs to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"token","type":"`string` \\| `string`[]","description":"The tokens to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string` \\| `string`[]","description":"The titles to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApiKeyType](../../../../../api_key/types/api_key.ApiKeyType/page.mdx)","description":"Filter the API keys by their type.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"revoked_at","type":"[OperatorMap](../../../../../api_key/types/api_key.OperatorMap/page.mdx)<null \\| Date>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"$and","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$or","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$eq","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T> \\| [ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ne","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$in","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$nin","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$not","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>","description":"API wrapper around the remoteQuery","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gt","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gte","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lt","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lte","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$like","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$re","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ilike","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$fulltext","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$overlap","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contains","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contained","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$exists","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"$and","type":"([FilterableApiKeyProps](../../../../../api_key/interfaces/api_key.FilterableApiKeyProps/page.mdx) \\| [BaseFilterable](../../../../../api_key/interfacLine truncated
|
||||
<TypeList types={[{"name":"UpdateApiKeysWorkflowInput","type":"[UpdateApiKeysWorkflowInput](../../../../types/core_flows.UpdateApiKeysWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"The data to update API keys.","expandable":false,"children":[{"name":"selector","type":"[FilterableApiKeyProps](../../../../../api_key/interfaces/api_key.FilterableApiKeyProps/page.mdx)","description":"The filters to select the API keys to update.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Search through the api key names and redacted keys using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"The IDs to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"token","type":"`string` \\| `string`[]","description":"The tokens to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string` \\| `string`[]","description":"The titles to filter the API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApiKeyType](../../../../../api_key/types/api_key.ApiKeyType/page.mdx)","description":"Filter the API keys by their type.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"revoked_at","type":"[OperatorMap](../../../../../api_key/types/api_key.OperatorMap/page.mdx)<null \\| Date>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"$and","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$or","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$eq","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T> \\| [ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ne","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$in","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$nin","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$not","type":"[Query](../../../../../api_key/types/api_key.Query/page.mdx)<T>","description":"API wrapper around the remoteQuery","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gt","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gte","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lt","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lte","type":"[ExpandScalar](../../../../../api_key/types/api_key.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$like","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$re","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ilike","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$fulltext","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$overlap","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contains","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contained","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$exists","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"$and","type":"([FilterableApiKeyProps](../../../../../api_key/interfaces/api_key.FilterableApiKeyProps/page.mdx) \\| [BaseFilterable](../..Line truncated
|
||||
|
||||
## Output
|
||||
|
||||
<TypeList types={[{"name":"ApiKeyDTO[]","type":"[ApiKeyDTO](../../../../../api_key/interfaces/api_key.ApiKeyDTO/page.mdx)[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"ApiKeyDTO","type":"[ApiKeyDTO](../../../../../api_key/interfaces/api_key.ApiKeyDTO/page.mdx)","optional":false,"defaultValue":"","description":"The API key details.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"token","type":"`string`","description":"The token of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"redacted","type":"`string`","description":"The redacted form of the API key's token. This is useful\nwhen showing portion of the token. For example `sk_...123`.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApiKeyType](../../../../../api_key/types/api_key.ApiKeyType/page.mdx)","description":"The type of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"last_used_at","type":"`null` \\| `Date`","description":"The date the API key was last used.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`string`","description":"Who created the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The date the API key was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The date the API key was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The date the API key was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"revoked_by","type":"`null` \\| `string`","description":"Who revoked the API key. For example,\nthe ID of the user that revoked it.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"revoked_at","type":"`null` \\| `Date`","description":"The date the API key was revoked.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="updateApiKeysWorkflow"/>
|
||||
<TypeList types={[{"name":"UpdateApiKeysWorkflowOutput","type":"[UpdateApiKeysWorkflowOutput](../../../../types/core_flows.UpdateApiKeysWorkflowOutput/page.mdx)","optional":false,"defaultValue":"","description":"The updated API keys.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"token","type":"`string`","description":"The token of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"redacted","type":"`string`","description":"The redacted form of the API key's token. This is useful\nwhen showing portion of the token. For example `sk_...123`.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ApiKeyType](../../../../../api_key/types/api_key.ApiKeyType/page.mdx)","description":"The type of the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"last_used_at","type":"`null` \\| `Date`","description":"The date the API key was last used.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`string`","description":"Who created the API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The date the API key was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The date the API key was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The date the API key was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"revoked_by","type":"`null` \\| `string`","description":"Who revoked the API key. For example,\nthe ID of the user that revoked it.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"revoked_at","type":"`null` \\| `Date`","description":"The date the API key was revoked.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="updateApiKeysWorkflow"/>
|
||||
+28
-15
@@ -12,24 +12,37 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `setAuthAppMetadataStep`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This step sets the `app_metadata` property of an auth identity.
|
||||
This step sets the `app_metadata` property of an auth identity. This is useful to
|
||||
associate a user (whether it's an admin user or customer) with an auth identity
|
||||
that allows them to authenticate into Medusa.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { setAuthAppMetadataStep } from "@medusajs/medusa/core-flows"
|
||||
You can learn more about auth identites in
|
||||
[this documentation](https://docs.medusajs.com/resources/commerce-modules/auth/auth-identity-and-actor-types).
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = setAuthAppMetadataStep({
|
||||
"authIdentityId": "{value}",
|
||||
"actorType": "{value}",
|
||||
"value": "{value}"
|
||||
})
|
||||
}
|
||||
)
|
||||
To use this for a custom actor type, check out [this guide](https://docs.medusajs.com/resources/commerce-modules/auth/create-actor-type)
|
||||
that explains how to create a custom `manager` actor type and manage its users.
|
||||
|
||||
## Example
|
||||
|
||||
To associate an auth identity with an actor type (user, customer, or other actor types):
|
||||
|
||||
```ts
|
||||
const data = setAuthAppMetadataStep({
|
||||
authIdentityId: "au_1234",
|
||||
actorType: "user", // or `customer`, or custom type
|
||||
value: "user_123"
|
||||
})
|
||||
```
|
||||
|
||||
To remove the association with an actor type, such as when deleting the user:
|
||||
|
||||
```ts
|
||||
const data = setAuthAppMetadataStep({
|
||||
authIdentityId: "au_1234",
|
||||
actorType: "user", // or `customer`, or custom type
|
||||
value: null
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
|
||||
+31
-18
@@ -13,7 +13,20 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `generateResetPasswordTokenWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/auth/workflows/generate-reset-password-token.ts#L13" />
|
||||
This workflow generates a reset password token for a user. It's used by the
|
||||
[Generate Reset Password Token for Admin](https://docs.medusajs.com/api/admin#auth\_postactor\_typeauth\_providerresetpassword)
|
||||
and [Generate Reset Password Token for Customer](https://docs.medusajs.com/api/store#auth\_postactor\_typeauth\_providerresetpassword)
|
||||
API Routes.
|
||||
|
||||
The workflow emits the `auth.password_reset` event, which you can listen to in
|
||||
a [subscriber](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers). Follow
|
||||
[this guide](https://docs.medusajs.com/resources/commerce-modules/auth/reset-password) to learn
|
||||
how to handle this event.
|
||||
|
||||
You can use this workflow within your customizations or your own custom workflows, allowing you to
|
||||
generate reset password tokens within your custom flows.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/auth/workflows/generate-reset-password-token.ts#L42" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -34,10 +47,10 @@ export async function POST(
|
||||
const { result } = await generateResetPasswordTokenWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"entityId": "{value}",
|
||||
"actorType": "{value}",
|
||||
"provider": "{value}",
|
||||
"secret": "{value}"
|
||||
entityId: "example@gmail.com",
|
||||
actorType: "customer",
|
||||
provider: "emailpass",
|
||||
secret: "jwt_123" // jwt secret
|
||||
}
|
||||
})
|
||||
|
||||
@@ -62,10 +75,10 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await generateResetPasswordTokenWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"entityId": "{value}",
|
||||
"actorType": "{value}",
|
||||
"provider": "{value}",
|
||||
"secret": "{value}"
|
||||
entityId: "example@gmail.com",
|
||||
actorType: "customer",
|
||||
provider: "emailpass",
|
||||
secret: "jwt_123" // jwt secret
|
||||
}
|
||||
})
|
||||
|
||||
@@ -90,10 +103,10 @@ export default async function myCustomJob(
|
||||
const { result } = await generateResetPasswordTokenWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"entityId": "{value}",
|
||||
"actorType": "{value}",
|
||||
"provider": "{value}",
|
||||
"secret": "{value}"
|
||||
entityId: "example@gmail.com",
|
||||
actorType: "customer",
|
||||
provider: "emailpass",
|
||||
secret: "jwt_123" // jwt secret
|
||||
}
|
||||
})
|
||||
|
||||
@@ -119,10 +132,10 @@ const myWorkflow = createWorkflow(
|
||||
const result = generateResetPasswordTokenWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"entityId": "{value}",
|
||||
"actorType": "{value}",
|
||||
"provider": "{value}",
|
||||
"secret": "{value}"
|
||||
entityId: "example@gmail.com",
|
||||
actorType: "customer",
|
||||
provider: "emailpass",
|
||||
secret: "jwt_123" // jwt secret
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -134,7 +147,7 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"generateResetPasswordTokenWorkflow","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":1},{"type":"step","name":"emitEventStep","description":"Emit an event.\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":2}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"generateResetPasswordTokenWorkflow","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":1},{"type":"step","name":"emitEventStep","description":"Emit an event.","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":2}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
|
||||
+12
-17
@@ -14,28 +14,23 @@ This documentation provides a reference to the `addShippingMethodToCartStep`. It
|
||||
|
||||
This step adds shipping methods to a cart.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { addShippingMethodToCartStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = addShippingMethodToCartStep({
|
||||
"shipping_methods": [{
|
||||
"name": "Kareem",
|
||||
"cart_id": "{value}",
|
||||
"amount": 38
|
||||
}]
|
||||
})
|
||||
}
|
||||
)
|
||||
```ts
|
||||
const data = addShippingMethodToCartStep({
|
||||
shipping_methods: [
|
||||
{
|
||||
name: "Standard Shipping",
|
||||
cart_id: "cart_123",
|
||||
amount: 10,
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"AddShippingMethodToCartStepInput","type":"[AddShippingMethodToCartStepInput](../../../../interfaces/core_flows.AddShippingMethodToCartStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"shipping_methods","type":"[CreateShippingMethodDTO](../../../../../cart/interfaces/cart.CreateShippingMethodDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"The name of the shipping method.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`string`","description":"The associated cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The amount of the shipping method.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"shipping_option_id","type":"`string`","description":"The amount of the shipping method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`Record<string, unknown>`","description":"The data of the shipping method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_lines","type":"[CreateTaxLineDTO](../../../../../cart/interfaces/cart.CreateTaxLineDTO/page.mdx)[]","description":"The tax lines of the shipping method.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the tax line.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rate","type":"`number`","description":"The rate of the tax line.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the tax line.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate_id","type":"`string`","description":"The associated tax rate's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The associated provider's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"item_id","type":"`string`","description":"The associated item's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"adjustments","type":"[CreateAdjustmentDTO](../../../../../cart/interfaces/cart.CreateAdjustmentDTO/page.mdx)[]","description":"The adjustments of the shipping method.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the promotion that lead to\nthis adjustment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The amount to adjust the original amount with.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the adjustment.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"promotion_id","type":"`string`","description":"The associated promotion's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The associated provider's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="addShippingMethodToCartStep"/>
|
||||
<TypeList types={[{"name":"AddShippingMethodToCartStepInput","type":"[AddShippingMethodToCartStepInput](../../../../interfaces/core_flows.AddShippingMethodToCartStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"shipping_methods","type":"[CreateShippingMethodDTO](../../../../../cart/interfaces/cart.CreateShippingMethodDTO/page.mdx)[]","description":"The shipping methods to add.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"The name of the shipping method.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`string`","description":"The associated cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The amount of the shipping method.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"shipping_option_id","type":"`string`","description":"The amount of the shipping method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`Record<string, unknown>`","description":"The data of the shipping method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_lines","type":"[CreateTaxLineDTO](../../../../../cart/interfaces/cart.CreateTaxLineDTO/page.mdx)[]","description":"The tax lines of the shipping method.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the tax line.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rate","type":"`number`","description":"The rate of the tax line.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the tax line.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate_id","type":"`string`","description":"The associated tax rate's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The associated provider's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"item_id","type":"`string`","description":"The associated item's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"adjustments","type":"[CreateAdjustmentDTO](../../../../../cart/interfaces/cart.CreateAdjustmentDTO/page.mdx)[]","description":"The adjustments of the shipping method.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the promotion that lead to\nthis adjustment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The amount to adjust the original amount with.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the adjustment.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"promotion_id","type":"`string`","description":"The associated promotion's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The associated provider's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="addShippingMethodToCartStep"/>
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+16
-22
@@ -12,31 +12,25 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `confirmInventoryStep`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This step confirms for one or more variants that their inventory has a required quantity.
|
||||
This step validates that items in the cart have sufficient inventory quantity.
|
||||
If an item doesn't have sufficient inventory, an error is thrown.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { confirmInventoryStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = confirmInventoryStep({
|
||||
"items": [{
|
||||
"inventory_item_id": "{value}",
|
||||
"required_quantity": 11,
|
||||
"allow_backorder": false,
|
||||
"quantity": 23,
|
||||
"location_ids": [
|
||||
"{value}"
|
||||
]
|
||||
}]
|
||||
})
|
||||
}
|
||||
)
|
||||
```ts
|
||||
confirmInventoryStep({
|
||||
items: [
|
||||
{
|
||||
inventory_item_id: "iitem_123",
|
||||
required_quantity: 1,
|
||||
allow_backorder: false,
|
||||
quantity: 1,
|
||||
location_ids: ["sloc_123"]
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"ConfirmVariantInventoryStepInput","type":"[ConfirmVariantInventoryStepInput](../../../../interfaces/core_flows.ConfirmVariantInventoryStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"items","type":"`object`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"inventory_item_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"required_quantity","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"allow_backorder","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"[BigNumberInput](../../../../../types/types/types.BigNumberInput/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"location_ids","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="confirmInventoryStep"/>
|
||||
<TypeList types={[{"name":"ConfirmVariantInventoryStepInput","type":"[ConfirmVariantInventoryStepInput](../../../../interfaces/core_flows.ConfirmVariantInventoryStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"items","type":"`object`[]","description":"The items to confirm inventory for.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"inventory_item_id","type":"`string`","description":"The ID of the inventory item associated with the line item's variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"required_quantity","type":"`number`","description":"The number of units a single quantity is equivalent to. For example, if a customer orders one quantity of the variant, Medusa checks the availability of the quantity multiplied by the\nvalue set for `required_quantity`. When the customer orders the quantity, Medusa reserves the ordered quantity multiplied by the value set for `required_quantity`.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"allow_backorder","type":"`boolean`","description":"Whether the variant can be ordered even if it's out of stock. If a variant has this enabled, the step doesn't throw an error.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"[BigNumberInput](../../../../../types/types/types.BigNumberInput/page.mdx)","description":"The quantity in the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"location_ids","type":"`string`[]","description":"The ID of the stock locations that the inventory quantity is available in.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="confirmInventoryStep"/>
|
||||
+4
-4
@@ -21,9 +21,9 @@ import { createCartsStep } from "@medusajs/medusa/core-flows"
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = createCartsStep([{
|
||||
"currency_code": "{value}"
|
||||
}])
|
||||
const data = createCartsStep({
|
||||
"currency_code": "mxn"
|
||||
})
|
||||
}
|
||||
)
|
||||
```
|
||||
@@ -31,7 +31,7 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"CreateCartDTO[]","type":"[CreateCartDTO](../../../../../cart/interfaces/cart.CreateCartDTO/page.mdx)[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"CreateCartDTO","type":"[CreateCartDTO](../../../../../cart/interfaces/cart.CreateCartDTO/page.mdx)","optional":false,"defaultValue":"","description":"The cart to be created.","expandable":false,"children":[{"name":"currency_code","type":"`string`","description":"The currency code of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"The associated region's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"The associated customer's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`string`","description":"The associated sales channel's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"The email of the customer that owns the cart.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address_id","type":"`string`","description":"The associated shipping address's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address_id","type":"`string`","description":"The associated billing address's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"`string` \\| [CreateAddressDTO](../../../../../cart/interfaces/cart.CreateAddressDTO/page.mdx)","description":"The shipping address of the cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"customer_id","type":"`string`","description":"The associated customer's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`string`","description":"The company of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`string`","description":"The first name of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`string`","description":"The last name of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`string`","description":"The first line of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`string`","description":"The second line of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`string`","description":"The city of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"The ISO two country code of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`string`","description":"The province of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`string`","description":"The postal code of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`string`","description":"The phone of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"billing_address","type":"`string` \\| [CreateAddressDTO](../../../../../cart/interfaces/cart.CreateAddressDTO/page.mdx)","description":"The billing address of the cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"customer_id","type":"`string`","description":"The associated customer's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`string`","description":"The company of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`string`","description":"The first name of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`string`","description":"The last name of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`string`","description":"The first line of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`string`","description":"The second line of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`string`","description":"The city of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","deLine truncated
|
||||
<TypeList types={[{"name":"CreateCartsStepInput","type":"[CreateCartsStepInput](../../../../types/core_flows.CreateCartsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"currency_code","type":"`string`","description":"The currency code of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"The associated region's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"The associated customer's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`string`","description":"The associated sales channel's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"The email of the customer that owns the cart.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address_id","type":"`string`","description":"The associated shipping address's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address_id","type":"`string`","description":"The associated billing address's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"`string` \\| [CreateAddressDTO](../../../../../cart/interfaces/cart.CreateAddressDTO/page.mdx)","description":"The shipping address of the cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"customer_id","type":"`string`","description":"The associated customer's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`string`","description":"The company of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`string`","description":"The first name of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`string`","description":"The last name of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`string`","description":"The first line of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`string`","description":"The second line of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`string`","description":"The city of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"The ISO two country code of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`string`","description":"The province of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`string`","description":"The postal code of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`string`","description":"The phone of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"billing_address","type":"`string` \\| [CreateAddressDTO](../../../../../cart/interfaces/cart.CreateAddressDTO/page.mdx)","description":"The billing address of the cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"customer_id","type":"`string`","description":"The associated customer's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`string`","description":"The company of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`string`","description":"The first name of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`string`","description":"The last name of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`string`","description":"The first line of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`string`","description":"The second line of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`string`","description":"The city of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"The ISO two country code of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`string`","description":"The province of the address.","Line truncated
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+13
-18
@@ -12,27 +12,22 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `createLineItemAdjustmentsStep`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This step creates line item adjustments in a cart.
|
||||
This step creates line item adjustments in a cart, such as when a promotion is applied.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { createLineItemAdjustmentsStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = createLineItemAdjustmentsStep({
|
||||
"lineItemAdjustmentsToCreate": [{
|
||||
"code": "{value}",
|
||||
"amount": 38,
|
||||
"item_id": "{value}"
|
||||
}]
|
||||
})
|
||||
}
|
||||
)
|
||||
```ts
|
||||
createLineItemAdjustmentsStep({
|
||||
lineItemAdjustmentsToCreate: [
|
||||
{
|
||||
item_id: "litem_123",
|
||||
code: "10OFF",
|
||||
amount: 10,
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"CreateLineItemAdjustmentsCartStepInput","type":"[CreateLineItemAdjustmentsCartStepInput](../../../../interfaces/core_flows.CreateLineItemAdjustmentsCartStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"lineItemAdjustmentsToCreate","type":"[CreateLineItemAdjustmentDTO](../../../../../cart/interfaces/cart.CreateLineItemAdjustmentDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the promotion that lead to\nthis adjustment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The amount to adjust the original amount with.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_id","type":"`string`","description":"The associated item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the adjustment.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"promotion_id","type":"`string`","description":"The associated promotion's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The associated provider's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createLineItemAdjustmentsStep"/>
|
||||
<TypeList types={[{"name":"CreateLineItemAdjustmentsCartStepInput","type":"[CreateLineItemAdjustmentsCartStepInput](../../../../interfaces/core_flows.CreateLineItemAdjustmentsCartStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"lineItemAdjustmentsToCreate","type":"[CreateLineItemAdjustmentDTO](../../../../../cart/interfaces/cart.CreateLineItemAdjustmentDTO/page.mdx)[]","description":"The line item adjustments to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the promotion that lead to\nthis adjustment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The amount to adjust the original amount with.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_id","type":"`string`","description":"The associated item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the adjustment.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"promotion_id","type":"`string`","description":"The associated promotion's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The associated provider's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createLineItemAdjustmentsStep"/>
|
||||
+12
-19
@@ -14,30 +14,23 @@ This documentation provides a reference to the `createLineItemsStep`. It belongs
|
||||
|
||||
This step creates line item in a cart.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { createLineItemsStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = createLineItemsStep({
|
||||
"id": "id_6rFekk11aJQdOk",
|
||||
"items": [{
|
||||
"title": "terebro",
|
||||
"quantity": 15,
|
||||
"unit_price": 47,
|
||||
"cart_id": "{value}"
|
||||
}]
|
||||
})
|
||||
}
|
||||
)
|
||||
```ts
|
||||
const data = createLineItemsStep({
|
||||
"id": "cart_123",
|
||||
"items": [{
|
||||
"title": "Shirt",
|
||||
"quantity": 1,
|
||||
"unit_price": 20,
|
||||
"cart_id": "cart_123",
|
||||
}]
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"CreateLineItemsCartStepInput","type":"[CreateLineItemsCartStepInput](../../../../interfaces/core_flows.CreateLineItemsCartStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[CreateLineItemForCartDTO](../../../../../cart/interfaces/cart.CreateLineItemForCartDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The quantity of the line item in the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"unit_price","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The unit price of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"cart_id","type":"`string`","description":"The associated cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`string`","description":"The subtitle of the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`string`","description":"The thumbnail of the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`string`","description":"The associated product's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_title","type":"`string`","description":"The title of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_description","type":"`string`","description":"The description of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_subtitle","type":"`string`","description":"The subtitle of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_type","type":"`string`","description":"The type of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_type_id","type":"`string`","description":"The ID of type of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_collection","type":"`string`","description":"The collection of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_handle","type":"`string`","description":"The handle of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_id","type":"`string`","description":"The associated variant's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_sku","type":"`string`","description":"The SKU of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_barcode","type":"`string`","description":"The barcode of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_title","type":"`string`","description":"The title of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_option_values","type":"`Record<string, unknown>`","description":"The option values of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Whether thLine truncated
|
||||
<TypeList types={[{"name":"CreateLineItemsCartStepInput","type":"[CreateLineItemsCartStepInput](../../../../interfaces/core_flows.CreateLineItemsCartStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart to create line items for.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[CreateLineItemForCartDTO](../../../../../cart/interfaces/cart.CreateLineItemForCartDTO/page.mdx)[]","description":"The line items to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The quantity of the line item in the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"unit_price","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The unit price of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"cart_id","type":"`string`","description":"The associated cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`string`","description":"The subtitle of the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`string`","description":"The thumbnail of the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`string`","description":"The associated product's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_title","type":"`string`","description":"The title of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_description","type":"`string`","description":"The description of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_subtitle","type":"`string`","description":"The subtitle of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_type","type":"`string`","description":"The type of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_type_id","type":"`string`","description":"The ID of type of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_collection","type":"`string`","description":"The collection of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_handle","type":"`string`","description":"The handle of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_id","type":"`string`","description":"The associated variant's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_sku","type":"`string`","description":"The SKU of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_barcode","type":"`string`","description":"The barcode of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_title","type":"`string`","description":"The title of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_option_values","type":"`Record<string, unknown>`","description":"The option values of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"nLine truncated
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+7
-15
@@ -14,26 +14,18 @@ This documentation provides a reference to the `createPaymentCollectionsStep`. I
|
||||
|
||||
This step creates payment collections in a cart.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { createPaymentCollectionsStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = createPaymentCollectionsStep([{
|
||||
"region_id": "{value}",
|
||||
"currency_code": "{value}",
|
||||
"amount": 39
|
||||
}])
|
||||
}
|
||||
)
|
||||
```ts
|
||||
const data = createPaymentCollectionsStep([{
|
||||
"currency_code": "usd",
|
||||
"amount": 40
|
||||
}])
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"CreatePaymentCollectionCartStepInput[]","type":"[CreatePaymentCollectionCartStepInput](../../../../types/core_flows.CreatePaymentCollectionCartStepInput/page.mdx)[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"CreatePaymentCollectionCartStepInput","type":"[CreatePaymentCollectionCartStepInput](../../../../types/core_flows.CreatePaymentCollectionCartStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"region_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberInput](../../../../../types/types/types.BigNumberInput/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"`Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createPaymentCollectionsStep"/>
|
||||
<TypeList types={[{"name":"CreatePaymentCollectionCartStepInput","type":"[CreatePaymentCollectionCartStepInput](../../../../types/core_flows.CreatePaymentCollectionCartStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberInput](../../../../../types/types/types.BigNumberInput/page.mdx)","description":"The payment collection's amount.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"`Record<string, unknown>`","description":"Custom key-value pairs to store in the payment collection.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createPaymentCollectionsStep"/>
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+10
-17
@@ -14,25 +14,18 @@ This documentation provides a reference to the `createShippingMethodAdjustmentsS
|
||||
|
||||
This step creates shipping method adjustments for a cart.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { createShippingMethodAdjustmentsStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = createShippingMethodAdjustmentsStep({
|
||||
"shippingMethodAdjustmentsToCreate": [{
|
||||
"shipping_method_id": "{value}",
|
||||
"code": "{value}",
|
||||
"amount": 42
|
||||
}]
|
||||
})
|
||||
}
|
||||
)
|
||||
```ts
|
||||
const data = createShippingMethodAdjustmentsStep({
|
||||
"shippingMethodAdjustmentsToCreate": [{
|
||||
"shipping_method_id": "sm_123",
|
||||
"code": "10OFF",
|
||||
"amount": 10
|
||||
}]
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"CreateShippingMethodAdjustmentsStepInput","type":"[CreateShippingMethodAdjustmentsStepInput](../../../../interfaces/core_flows.CreateShippingMethodAdjustmentsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"shippingMethodAdjustmentsToCreate","type":"[CreateShippingMethodAdjustmentDTO](../../../../../cart/interfaces/cart.CreateShippingMethodAdjustmentDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"shipping_method_id","type":"`string`","description":"The associated shipping method's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"The code of the promotion that lead to\nthis adjustment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The amount to adjust the original amount with.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"description","type":"`string`","description":"The description of the shipping method adjustment.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"promotion_id","type":"`string`","description":"The associated promotion's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The associated provider's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createShippingMethodAdjustmentsStep"/>
|
||||
<TypeList types={[{"name":"CreateShippingMethodAdjustmentsStepInput","type":"[CreateShippingMethodAdjustmentsStepInput](../../../../interfaces/core_flows.CreateShippingMethodAdjustmentsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"shippingMethodAdjustmentsToCreate","type":"[CreateShippingMethodAdjustmentDTO](../../../../../cart/interfaces/cart.CreateShippingMethodAdjustmentDTO/page.mdx)[]","description":"The shipping method adjustments to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"shipping_method_id","type":"`string`","description":"The associated shipping method's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"The code of the promotion that lead to\nthis adjustment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The amount to adjust the original amount with.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"description","type":"`string`","description":"The description of the shipping method adjustment.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"promotion_id","type":"`string`","description":"The associated promotion's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The associated provider's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createShippingMethodAdjustmentsStep"/>
|
||||
+1
-1
@@ -30,7 +30,7 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"regionId","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="findOneOrAnyRegionStep"/>
|
||||
<TypeList types={[{"name":"FindOneOrAnyRegionStepInput","type":"[FindOneOrAnyRegionStepInput](../../../../types/core_flows.FindOneOrAnyRegionStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"regionId","type":"`string`","description":"The ID of the region to find.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="findOneOrAnyRegionStep"/>
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+2
-2
@@ -31,8 +31,8 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"FindOrCreateCustomerStepInput","type":"[FindOrCreateCustomerStepInput](../../../../interfaces/core_flows.FindOrCreateCustomerStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"customerId","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="findOrCreateCustomerStep"/>
|
||||
<TypeList types={[{"name":"FindOrCreateCustomerStepInput","type":"[FindOrCreateCustomerStepInput](../../../../interfaces/core_flows.FindOrCreateCustomerStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"customerId","type":"`null` \\| `string`","description":"The ID of the customer to find.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"If the `customerId` isn't specified,\nfind a customer with this email or create a new customer having this email.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="findOrCreateCustomerStep"/>
|
||||
|
||||
## Output
|
||||
|
||||
<TypeList types={[{"name":"FindOrCreateCustomerOutputStepOutput","type":"[FindOrCreateCustomerOutputStepOutput](../../../../interfaces/core_flows.FindOrCreateCustomerOutputStepOutput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"customer","type":"`null` \\| [CustomerDTO](../../../../../customer/interfaces/customer.CustomerDTO/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"The email of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"A flag indicating if customer has an account or not.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"default_billing_address_id","type":"`null` \\| `string`","description":"The associated default billing address's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"default_shipping_address_id","type":"`null` \\| `string`","description":"The associated default shipping address's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company_name","type":"`null` \\| `string`","description":"The company name of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"addresses","type":"[CustomerAddressDTO](../../../../../customer/interfaces/customer.CustomerAddressDTO/page.mdx)[]","description":"The addresses of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the customer address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"Whether the customer address is default shipping.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"Whether the customer address is default billing.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"The associated customer's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string`","description":"The created at of the customer address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"The updated at of the customer address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`string`","description":"The address name of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`string`","description":"The company of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`string`","description":"The first name of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`string`","description":"The last name of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`string`","description":"The address 1 of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`string`","description":"The address 2 of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`string`","description":"The city of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"The country code of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`string`","description":"The province of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`string`","description":"The postal code of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`string`","description":"The phone of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":falsLine truncated
|
||||
<TypeList types={[{"name":"FindOrCreateCustomerOutputStepOutput","type":"[FindOrCreateCustomerOutputStepOutput](../../../../interfaces/core_flows.FindOrCreateCustomerOutputStepOutput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"customer","type":"`null` \\| [CustomerDTO](../../../../../customer/interfaces/customer.CustomerDTO/page.mdx)","description":"The customer found or created, if any.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"The email of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"A flag indicating if customer has an account or not.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"default_billing_address_id","type":"`null` \\| `string`","description":"The associated default billing address's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"default_shipping_address_id","type":"`null` \\| `string`","description":"The associated default shipping address's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company_name","type":"`null` \\| `string`","description":"The company name of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"addresses","type":"[CustomerAddressDTO](../../../../../customer/interfaces/customer.CustomerAddressDTO/page.mdx)[]","description":"The addresses of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the customer address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"Whether the customer address is default shipping.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"Whether the customer address is default billing.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"The associated customer's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string`","description":"The created at of the customer address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"The updated at of the customer address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`string`","description":"The address name of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`string`","description":"The company of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`string`","description":"The first name of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`string`","description":"The last name of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`string`","description":"The address 1 of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`string`","description":"The address 2 of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`string`","description":"The city of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"The country code of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`string`","description":"The province of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`string`","description":"The postal code of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`string`","description":"The phone of the customer address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":trLine truncated
|
||||
+1
-1
@@ -31,7 +31,7 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"FindSalesChannelStepInput","type":"[FindSalesChannelStepInput](../../../../interfaces/core_flows.FindSalesChannelStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"salesChannelId","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="findSalesChannelStep"/>
|
||||
<TypeList types={[{"name":"FindSalesChannelStepInput","type":"[FindSalesChannelStepInput](../../../../interfaces/core_flows.FindSalesChannelStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"salesChannelId","type":"`null` \\| `string`","description":"The ID of the sales channel to find.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="findSalesChannelStep"/>
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+15
-151
@@ -15,162 +15,26 @@ This documentation provides a reference to the `getActionsToComputeFromPromotion
|
||||
This step retrieves the actions to compute based on the promotions
|
||||
applied on a cart.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { getActionsToComputeFromPromotionsStep } from "@medusajs/medusa/core-flows"
|
||||
:::tip
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = getActionsToComputeFromPromotionsStep({
|
||||
"cart": {
|
||||
"id": "id_zo2WfWgPkxMjG",
|
||||
"currency_code": "{value}",
|
||||
"original_item_total": {
|
||||
"numeric": 0
|
||||
},
|
||||
"original_item_subtotal": {
|
||||
"numeric": 16
|
||||
},
|
||||
"original_item_tax_total": {
|
||||
"numeric": 50
|
||||
},
|
||||
"item_total": {
|
||||
"numeric": 5
|
||||
},
|
||||
"item_subtotal": {
|
||||
"numeric": 31
|
||||
},
|
||||
"item_tax_total": {
|
||||
"numeric": 16
|
||||
},
|
||||
"original_total": {
|
||||
"numeric": 7
|
||||
},
|
||||
"original_subtotal": {
|
||||
"numeric": 4
|
||||
},
|
||||
"original_tax_total": {
|
||||
"numeric": 2
|
||||
},
|
||||
"total": {
|
||||
"numeric": 8
|
||||
},
|
||||
"subtotal": {
|
||||
"numeric": 50
|
||||
},
|
||||
"tax_total": {
|
||||
"numeric": 42
|
||||
},
|
||||
"discount_total": {
|
||||
"numeric": 48
|
||||
},
|
||||
"discount_tax_total": {
|
||||
"numeric": 43
|
||||
},
|
||||
"gift_card_total": {
|
||||
"numeric": 40
|
||||
},
|
||||
"gift_card_tax_total": {
|
||||
"numeric": 21
|
||||
},
|
||||
"shipping_total": {
|
||||
"numeric": 41
|
||||
},
|
||||
"shipping_subtotal": {
|
||||
"numeric": 4
|
||||
},
|
||||
"shipping_tax_total": {
|
||||
"numeric": 47
|
||||
},
|
||||
"original_shipping_total": {
|
||||
"numeric": 13
|
||||
},
|
||||
"original_shipping_subtotal": {
|
||||
"numeric": 21
|
||||
},
|
||||
"original_shipping_tax_total": {
|
||||
"numeric": 32
|
||||
},
|
||||
"raw_original_item_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_item_subtotal": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_item_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_item_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_item_subtotal": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_item_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_subtotal": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_subtotal": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_discount_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_discount_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_gift_card_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_gift_card_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_shipping_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_shipping_subtotal": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_shipping_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_shipping_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_shipping_subtotal": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_shipping_tax_total": {
|
||||
"value": "{value}"
|
||||
}
|
||||
},
|
||||
"promotionCodesToApply": [
|
||||
"{value}"
|
||||
]
|
||||
})
|
||||
}
|
||||
)
|
||||
You can use the [retrieveCartStep](../core_flows.Cart.Steps_Cart.retrieveCartStep/page.mdx) to retrieve a cart's details.
|
||||
|
||||
:::
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
const data = getActionsToComputeFromPromotionsStep({
|
||||
// retrieve the details of the cart from another workflow
|
||||
// or in another step using the Cart Module's service
|
||||
cart,
|
||||
promotionCodesToApply: ["10OFF"]
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"GetActionsToComputeFromPromotionsStepInput","type":"[GetActionsToComputeFromPromotionsStepInput](../../../../interfaces/core_flows.GetActionsToComputeFromPromotionsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"cart","type":"[CartDTO](../../../../../cart/interfaces/cart.CartDTO/page.mdx)","description":"The cart details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the cart","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_item_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item subtotal of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_item_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item tax total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item subtotal of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item tax total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":Line truncated
|
||||
<TypeList types={[{"name":"GetActionsToComputeFromPromotionsStepInput","type":"[GetActionsToComputeFromPromotionsStepInput](../../../../interfaces/core_flows.GetActionsToComputeFromPromotionsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"cart","type":"[CartDTO](../../../../../cart/interfaces/cart.CartDTO/page.mdx)","description":"The cart to compute the actions for.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the cart","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_item_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item subtotal of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_item_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item tax total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item subtotal of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item tax total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"nameLine truncated
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+13
-20
@@ -15,31 +15,24 @@ This documentation provides a reference to the `getLineItemActionsStep`. It belo
|
||||
This step returns lists of cart line items to create or update based on the
|
||||
provided input.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { getLineItemActionsStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = getLineItemActionsStep({
|
||||
"id": "id_XFQdKL3gqtUVNd",
|
||||
"items": [{
|
||||
"title": "tener",
|
||||
"quantity": 50,
|
||||
"unit_price": 46,
|
||||
"cart_id": "{value}"
|
||||
}]
|
||||
})
|
||||
}
|
||||
)
|
||||
```ts
|
||||
const data = getLineItemActionsStep({
|
||||
"id": "cart_123",
|
||||
"items": [{
|
||||
"title": "Shirt",
|
||||
"quantity": 1,
|
||||
"unit_price": 50,
|
||||
"cart_id": "cart_123",
|
||||
}]
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"GetLineItemActionsStepInput","type":"[GetLineItemActionsStepInput](../../../../interfaces/core_flows.GetLineItemActionsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[CreateLineItemForCartDTO](../../../../../cart/interfaces/cart.CreateLineItemForCartDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The quantity of the line item in the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"unit_price","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The unit price of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"cart_id","type":"`string`","description":"The associated cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`string`","description":"The subtitle of the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`string`","description":"The thumbnail of the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`string`","description":"The associated product's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_title","type":"`string`","description":"The title of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_description","type":"`string`","description":"The description of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_subtitle","type":"`string`","description":"The subtitle of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_type","type":"`string`","description":"The type of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_type_id","type":"`string`","description":"The ID of type of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_collection","type":"`string`","description":"The collection of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_handle","type":"`string`","description":"The handle of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_id","type":"`string`","description":"The associated variant's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_sku","type":"`string`","description":"The SKU of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_barcode","type":"`string`","description":"The barcode of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_title","type":"`string`","description":"The title of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_option_values","type":"`Record<string, unknown>`","description":"The option values of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Whether the lLine truncated
|
||||
<TypeList types={[{"name":"GetLineItemActionsStepInput","type":"[GetLineItemActionsStepInput](../../../../interfaces/core_flows.GetLineItemActionsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart to create line items for.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[CreateLineItemForCartDTO](../../../../../cart/interfaces/cart.CreateLineItemForCartDTO/page.mdx)[]","description":"The line items to create or update.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The quantity of the line item in the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"unit_price","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The unit price of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"cart_id","type":"`string`","description":"The associated cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`string`","description":"The subtitle of the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`string`","description":"The thumbnail of the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`string`","description":"The associated product's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_title","type":"`string`","description":"The title of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_description","type":"`string`","description":"The description of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_subtitle","type":"`string`","description":"The subtitle of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_type","type":"`string`","description":"The type of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_type_id","type":"`string`","description":"The ID of type of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_collection","type":"`string`","description":"The collection of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_handle","type":"`string`","description":"The handle of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_id","type":"`string`","description":"The associated variant's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_sku","type":"`string`","description":"The SKU of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_barcode","type":"`string`","description":"The barcode of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_title","type":"`string`","description":"The title of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_option_values","type":"`Record<string, unknown>`","description":"The option values of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":Line truncated
|
||||
|
||||
## Output
|
||||
|
||||
<TypeList types={[{"name":"WorkflowDataProperties","type":"[WorkflowDataProperties](../../../../../workflows/types/workflows.WorkflowDataProperties/page.mdx)<object>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"itemsToCreate","type":"[CreateLineItemForCartDTO](../../../../../cart/interfaces/cart.CreateLineItemForCartDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The quantity of the line item in the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"unit_price","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The unit price of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`string`","description":"The associated cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`string`","description":"The subtitle of the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`string`","description":"The thumbnail of the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`string`","description":"The associated product's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_title","type":"`string`","description":"The title of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_description","type":"`string`","description":"The description of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_subtitle","type":"`string`","description":"The subtitle of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_type","type":"`string`","description":"The type of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_type_id","type":"`string`","description":"The ID of type of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_collection","type":"`string`","description":"The collection of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_handle","type":"`string`","description":"The handle of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_id","type":"`string`","description":"The associated variant's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_sku","type":"`string`","description":"The SKU of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_barcode","type":"`string`","description":"The barcode of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_title","type":"`string`","description":"The title of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_option_values","type":"`Record<string, unknown>`","description":"The option values of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Whether the line item requires shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_discountable","type":"`boolean`","description":"Whether the line item is discountable.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_tax_inclusive","type":"`boolean`","description":"Whether the line item's amount is tax inclusive.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_custom_price","type":"`boolean`","description":"Whether the line item's amount is a custom price.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"compare_at_unit_price","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The calculated price of the line item after applying promotions.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_lines","type":"[CreateTaxLineDTO](../../../../../cart/interfaces/cart.CreateTaxLineDTO/page.mdx)[]","description":"The tax lines of the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"adjustments","type":"[CreateAdjustmentDTO](../../../../../cart/interfaces/cart.CreateAdjustmentDTO/page.mdx)[]"Line truncated
|
||||
<TypeList types={[{"name":"GetLineItemActionsStepOutput","type":"[GetLineItemActionsStepOutput](../../../../interfaces/core_flows.GetLineItemActionsStepOutput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"itemsToCreate","type":"[CreateLineItemForCartDTO](../../../../../cart/interfaces/cart.CreateLineItemForCartDTO/page.mdx)[]","description":"The line items to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The quantity of the line item in the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"unit_price","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The unit price of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"cart_id","type":"`string`","description":"The associated cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`string`","description":"The subtitle of the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`string`","description":"The thumbnail of the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`string`","description":"The associated product's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_title","type":"`string`","description":"The title of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_description","type":"`string`","description":"The description of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_subtitle","type":"`string`","description":"The subtitle of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_type","type":"`string`","description":"The type of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_type_id","type":"`string`","description":"The ID of type of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_collection","type":"`string`","description":"The collection of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_handle","type":"`string`","description":"The handle of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_id","type":"`string`","description":"The associated variant's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_sku","type":"`string`","description":"The SKU of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_barcode","type":"`string`","description":"The barcode of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_title","type":"`string`","description":"The title of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_option_values","type":"`Record<string, unknown>`","description":"The option values of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Whether the line item requires shipping.","optional":true,"defaultValue":"","expandable":falseLine truncated
|
||||
+20
-12
@@ -14,24 +14,32 @@ This documentation provides a reference to the `getPromotionCodesToApply`. It be
|
||||
|
||||
This step retrieves the promotion codes to apply on a cart.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { getPromotionCodesToApply } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = getPromotionCodesToApply({
|
||||
"cart": {}
|
||||
})
|
||||
}
|
||||
```ts
|
||||
const data = getPromotionCodesToApply(
|
||||
{
|
||||
cart: {
|
||||
items: [
|
||||
{
|
||||
adjustments: [{ code: "PROMO10" }]
|
||||
}
|
||||
],
|
||||
shipping_methods: [
|
||||
{
|
||||
adjustments: [{ code: "SHIPFREE" }]
|
||||
}
|
||||
]
|
||||
},
|
||||
promo_codes: ["NEWYEAR20"],
|
||||
action: PromotionActions.ADD
|
||||
},
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"GetPromotionCodesToApplyStepInput","type":"[GetPromotionCodesToApplyStepInput](../../../../interfaces/core_flows.GetPromotionCodesToApplyStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"cart","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"items","type":"`object`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"adjustments","type":"`object`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"shipping_methods","type":"`object`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"adjustments","type":"`object`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"promo_codes","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"action","type":"[ADD](../../../../../utils/PromotionUtils/enums/utils.PromotionUtils.PromotionActions/page.mdx#add) \\| [REMOVE](../../../../../utils/PromotionUtils/enums/utils.PromotionUtils.PromotionActions/page.mdx#remove) \\| [REPLACE](../../../../../utils/PromotionUtils/enums/utils.PromotionUtils.PromotionActions/page.mdx#replace)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="getPromotionCodesToApply"/>
|
||||
<TypeList types={[{"name":"GetPromotionCodesToApplyStepInput","type":"[GetPromotionCodesToApplyStepInput](../../../../interfaces/core_flows.GetPromotionCodesToApplyStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"cart","type":"`object`","description":"The cart containing items and shipping methods.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"items","type":"`object`[]","description":"The cart's items and the promotion adjustments applied to them.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"adjustments","type":"`object`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"shipping_methods","type":"`object`[]","description":"The cart's shipping methods and the promotion adjustments applied to them.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"adjustments","type":"`object`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"promo_codes","type":"`string`[]","description":"the promotion codes to be applied to the cart.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"action","type":"[ADD](../../../../../utils/PromotionUtils/enums/utils.PromotionUtils.PromotionActions/page.mdx#add) \\| [REMOVE](../../../../../utils/PromotionUtils/enums/utils.PromotionUtils.PromotionActions/page.mdx#remove) \\| [REPLACE](../../../../../utils/PromotionUtils/enums/utils.PromotionUtils.PromotionActions/page.mdx#replace)","description":"Whether to add, remove, or replace promotion codes.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="getPromotionCodesToApply"/>
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+22
-14
@@ -11,23 +11,31 @@ This documentation provides a reference to the `getVariantPriceSetsStep`. It bel
|
||||
|
||||
This step retrieves the calculated price sets of the specified variants.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { getVariantPriceSetsStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = getVariantPriceSetsStep({
|
||||
"variantIds": [
|
||||
"{value}"
|
||||
]
|
||||
})
|
||||
To retrieve a variant's price sets:
|
||||
|
||||
```ts
|
||||
const data = getVariantPriceSetsStep({
|
||||
variantIds: ["variant_123"],
|
||||
})
|
||||
```
|
||||
|
||||
To retrieve the calculated price sets of a variant:
|
||||
|
||||
```ts
|
||||
const data = getVariantPriceSetsStep({
|
||||
variantIds: ["variant_123"],
|
||||
context: {
|
||||
currency_code: "usd"
|
||||
}
|
||||
)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"GetVariantPriceSetsStepInput","type":"[GetVariantPriceSetsStepInput](../../../../interfaces/core_flows.GetVariantPriceSetsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"variantIds","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"context","type":"`Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="getVariantPriceSetsStep"/>
|
||||
<TypeList types={[{"name":"GetVariantPriceSetsStepInput","type":"[GetVariantPriceSetsStepInput](../../../../interfaces/core_flows.GetVariantPriceSetsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"variantIds","type":"`string`[]","description":"The IDs of the variants to get price sets for.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"context","type":"`Record<string, unknown>`","description":"The context to use when calculating the price sets.\n\nLearn more in [this documentation](https://docs.medusajs.com/resources/commerce-modules/product/guides/price#retrieve-calculated-price-for-a-context).","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="getVariantPriceSetsStep"/>
|
||||
|
||||
## Output
|
||||
|
||||
<TypeList types={[{"name":"WorkflowDataProperties","type":"[WorkflowDataProperties](../../../../../workflows/types/workflows.WorkflowDataProperties/page.mdx)<object>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="getVariantPriceSetsStep"/>
|
||||
+6
-9
@@ -11,18 +11,15 @@ This documentation provides a reference to the `getVariantsStep`. It belongs to
|
||||
|
||||
This step retrieves variants matching the specified filters.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { getVariantsStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = getVariantsStep({})
|
||||
```ts
|
||||
const data = getVariantsStep({
|
||||
filter: {
|
||||
id: "variant_123"
|
||||
}
|
||||
)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
|
||||
+12
-21
@@ -15,32 +15,23 @@ This documentation provides a reference to the `prepareAdjustmentsFromPromotionA
|
||||
This step prepares the line item or shipping method adjustments using
|
||||
actions computed by the Promotion Module.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { prepareAdjustmentsFromPromotionActionsStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = prepareAdjustmentsFromPromotionActionsStep({
|
||||
"actions": [{
|
||||
"action": "{value}",
|
||||
"item_id": "{value}",
|
||||
"amount": 26,
|
||||
"code": "{value}",
|
||||
"adjustment_id": "{value}",
|
||||
"shipping_method_id": "{value}"
|
||||
}]
|
||||
})
|
||||
}
|
||||
)
|
||||
```ts
|
||||
const data = prepareAdjustmentsFromPromotionActionsStep({
|
||||
"actions": [{
|
||||
"action": "addItemAdjustment",
|
||||
"item_id": "litem_123",
|
||||
"amount": 10,
|
||||
"code": "10OFF",
|
||||
}]
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"PrepareAdjustmentsFromPromotionActionsStepInput","type":"[PrepareAdjustmentsFromPromotionActionsStepInput](../../../../interfaces/core_flows.PrepareAdjustmentsFromPromotionActionsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"actions","type":"[ComputeActions](../../../../../promotion/types/promotion.ComputeActions/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"action","type":"`\"addItemAdjustment\"`","description":"The type of action.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_id","type":"`string`","description":"The associated item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberInput](../../../../../promotion/types/promotion.BigNumberInput/page.mdx)","description":"The amount to remove off the item's total.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../promotion/types/promotion.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"code","type":"`string`","description":"The promotion's code.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"adjustment_id","type":"`string`","description":"The associated adjustment's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_method_id","type":"`string`","description":"The associated shipping method's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The promotion's description.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="prepareAdjustmentsFromPromotionActionsStep"/>
|
||||
<TypeList types={[{"name":"PrepareAdjustmentsFromPromotionActionsStepInput","type":"[PrepareAdjustmentsFromPromotionActionsStepInput](../../../../interfaces/core_flows.PrepareAdjustmentsFromPromotionActionsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"actions","type":"[ComputeActions](../../../../../promotion/types/promotion.ComputeActions/page.mdx)[]","description":"The actions computed by the Promotion Module.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"action","type":"`\"addItemAdjustment\"`","description":"The type of action.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_id","type":"`string`","description":"The associated item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberInput](../../../../../promotion/types/promotion.BigNumberInput/page.mdx)","description":"The amount to remove off the item's total.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../promotion/types/promotion.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"code","type":"`string`","description":"The promotion's code.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"adjustment_id","type":"`string`","description":"The associated adjustment's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_method_id","type":"`string`","description":"The associated shipping method's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The promotion's description.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="prepareAdjustmentsFromPromotionActionsStep"/>
|
||||
|
||||
## Output
|
||||
|
||||
<TypeList types={[{"name":"WorkflowDataProperties","type":"[WorkflowDataProperties](../../../../../workflows/types/workflows.WorkflowDataProperties/page.mdx)<object>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"lineItemAdjustmentsToCreate","type":"`object`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"","optional":false,"defaultValue":"action.code","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberInput](../../../../../types/types/types.BigNumberInput/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"promotion_id","type":"`undefined` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"lineItemAdjustmentIdsToRemove","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shippingMethodAdjustmentsToCreate","type":"`object`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"","optional":false,"defaultValue":"action.code","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberInput](../../../../../types/types/types.BigNumberInput/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_method_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"promotion_id","type":"`undefined` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"shippingMethodAdjustmentIdsToRemove","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"computedPromotionCodes","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="prepareAdjustmentsFromPromotionActionsStep"/>
|
||||
<TypeList types={[{"name":"PrepareAdjustmentsFromPromotionActionsStepOutput","type":"[PrepareAdjustmentsFromPromotionActionsStepOutput](../../../../interfaces/core_flows.PrepareAdjustmentsFromPromotionActionsStepOutput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"lineItemAdjustmentsToCreate","type":"`object`[]","description":"The line item adjustments to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The promotion code that computed the adjustment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number`","description":"The amount of the adjustment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_id","type":"`string`","description":"The ID of the line item to adjust.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"promotion_id","type":"`string`","description":"The ID of the applied promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"lineItemAdjustmentIdsToRemove","type":"`string`[]","description":"The line item adjustment IDs to remove.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shippingMethodAdjustmentsToCreate","type":"`object`[]","description":"The shipping method adjustments to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The promotion code that computed the adjustment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number`","description":"The amount of the adjustment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_method_id","type":"`string`","description":"The ID of the shipping method to adjust.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"promotion_id","type":"`string`","description":"The ID of the applied promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"shippingMethodAdjustmentIdsToRemove","type":"`string`[]","description":"The shipping method adjustment IDs to remove.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"computedPromotionCodes","type":"`string`[]","description":"The promotion codes that were computed.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="prepareAdjustmentsFromPromotionActionsStep"/>
|
||||
+1
-1
@@ -33,4 +33,4 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"RemoveLineItemAdjustmentsStepInput","type":"[RemoveLineItemAdjustmentsStepInput](../../../../interfaces/core_flows.RemoveLineItemAdjustmentsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"lineItemAdjustmentIdsToRemove","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="removeLineItemAdjustmentsStep"/>
|
||||
<TypeList types={[{"name":"RemoveLineItemAdjustmentsStepInput","type":"[RemoveLineItemAdjustmentsStepInput](../../../../interfaces/core_flows.RemoveLineItemAdjustmentsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"lineItemAdjustmentIdsToRemove","type":"`string`[]","description":"The IDs of the line item adjustments to remove.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="removeLineItemAdjustmentsStep"/>
|
||||
+1
-1
@@ -33,4 +33,4 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"RemoveShippingMethodAdjustmentsStepInput","type":"[RemoveShippingMethodAdjustmentsStepInput](../../../../interfaces/core_flows.RemoveShippingMethodAdjustmentsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"shippingMethodAdjustmentIdsToRemove","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="removeShippingMethodAdjustmentsStep"/>
|
||||
<TypeList types={[{"name":"RemoveShippingMethodAdjustmentsStepInput","type":"[RemoveShippingMethodAdjustmentsStepInput](../../../../interfaces/core_flows.RemoveShippingMethodAdjustmentsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"shippingMethodAdjustmentIdsToRemove","type":"`string`[]","description":"The IDs of the shipping method adjustments to remove.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="removeShippingMethodAdjustmentsStep"/>
|
||||
+1
-1
@@ -33,7 +33,7 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"RemoveShippingMethodFromCartStepInput","type":"[RemoveShippingMethodFromCartStepInput](../../../../interfaces/core_flows.RemoveShippingMethodFromCartStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"shipping_method_ids","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="removeShippingMethodFromCartStep"/>
|
||||
<TypeList types={[{"name":"RemoveShippingMethodFromCartStepInput","type":"[RemoveShippingMethodFromCartStepInput](../../../../interfaces/core_flows.RemoveShippingMethodFromCartStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"shipping_method_ids","type":"`string`[]","description":"The IDs of the shipping methods to remove.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="removeShippingMethodFromCartStep"/>
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+14
-21
@@ -16,32 +16,25 @@ This documentation provides a reference to the `reserveInventoryStep`. It belong
|
||||
This step reserves the quantity of line items from the associated
|
||||
variant's inventory.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { reserveInventoryStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = reserveInventoryStep({
|
||||
"items": [{
|
||||
"inventory_item_id": "{value}",
|
||||
"required_quantity": 40,
|
||||
"allow_backorder": false,
|
||||
"quantity": 44,
|
||||
"location_ids": [
|
||||
"{value}"
|
||||
]
|
||||
}]
|
||||
})
|
||||
}
|
||||
)
|
||||
```ts
|
||||
const data = reserveInventoryStep({
|
||||
"items": [{
|
||||
"inventory_item_id": "iitem_123",
|
||||
"required_quantity": 1,
|
||||
"allow_backorder": false,
|
||||
"quantity": 1,
|
||||
"location_ids": [
|
||||
"sloc_123"
|
||||
]
|
||||
}]
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"ReserveVariantInventoryStepInput","type":"[ReserveVariantInventoryStepInput](../../../../interfaces/core_flows.ReserveVariantInventoryStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"items","type":"`object`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"inventory_item_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"required_quantity","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"allow_backorder","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"[BigNumberInput](../../../../../types/types/types.BigNumberInput/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"location_ids","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="reserveInventoryStep"/>
|
||||
<TypeList types={[{"name":"ReserveVariantInventoryStepInput","type":"[ReserveVariantInventoryStepInput](../../../../interfaces/core_flows.ReserveVariantInventoryStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"items","type":"`object`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"inventory_item_id","type":"`string`","description":"The ID of the inventory item to reserve quantities from.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"required_quantity","type":"`number`","description":"The number of units a single quantity is equivalent to. For example, if a customer orders one quantity of the variant, Medusa checks the availability of the quantity multiplied by the\nvalue set for `required_quantity`. When the customer orders the quantity, Medusa reserves the ordered quantity multiplied by the value set for `required_quantity`.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"allow_backorder","type":"`boolean`","description":"Whether the variant can be ordered even if it's out of stock.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"[BigNumberInput](../../../../../types/types/types.BigNumberInput/page.mdx)","description":"The quantity to reserve.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"location_ids","type":"`string`[]","description":"The IDs of stock locations to reserve the item's quantity in.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"The ID for the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="reserveInventoryStep"/>
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = retrieveCartStep({
|
||||
"id": "id_8DpKO8h0vK4"
|
||||
"id": "id_Sesn0gbIImwBSxkoNWw3"
|
||||
})
|
||||
}
|
||||
)
|
||||
@@ -28,7 +28,7 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"RetrieveCartStepInput","type":"[RetrieveCartStepInput](../../../../interfaces/core_flows.RetrieveCartStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"config","type":"[FindConfig](../../../../../medusa/interfaces/medusa.FindConfig/page.mdx)<[CartDTO](../../../../../cart/interfaces/cart.CartDTO/page.mdx)>","description":"An object that is used to configure how an entity is retrieved from the database. It accepts as a typed parameter an \n\n`Entity`\n\n class,\nwhich provides correct typing of field names in its properties.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"select","type":"(`string` \\| keyof Entity)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"skip","type":"`null` \\| `number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"take","type":"`null` \\| `number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"[FindConfigOrder](../../../../../medusa/types/medusa.FindConfigOrder/page.mdx)","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC`\nto sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the\n`SoftDeletableEntity` class.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"filters","type":"`Record<string, any>`","description":"Enable ORM specific defined filters","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`Record<string, any>`","description":"Enable ORM specific defined options","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="retrieveCartStep"/>
|
||||
<TypeList types={[{"name":"RetrieveCartStepInput","type":"[RetrieveCartStepInput](../../../../interfaces/core_flows.RetrieveCartStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart to retrieve.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"config","type":"[FindConfig](../../../../../medusa/interfaces/medusa.FindConfig/page.mdx)<[CartDTO](../../../../../cart/interfaces/cart.CartDTO/page.mdx)>","description":"An object that is used to configure how an entity is retrieved from the database. It accepts as a typed parameter an \n\n`Entity`\n\n class,\nwhich provides correct typing of field names in its properties.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"select","type":"(`string` \\| keyof Entity)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"skip","type":"`null` \\| `number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"take","type":"`null` \\| `number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"[FindConfigOrder](../../../../../medusa/types/medusa.FindConfigOrder/page.mdx)","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC`\nto sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the\n`SoftDeletableEntity` class.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"filters","type":"`Record<string, any>`","description":"Enable ORM specific defined filters","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`Record<string, any>`","description":"Enable ORM specific defined options","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="retrieveCartStep"/>
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+28
-42
@@ -14,50 +14,36 @@ This documentation provides a reference to the `setTaxLinesForItemsStep`. It bel
|
||||
|
||||
This step sets the tax lines of shipping methods and line items in a cart.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { setTaxLinesForItemsStep } from "@medusajs/medusa/core-flows"
|
||||
:::tip
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = setTaxLinesForItemsStep({
|
||||
"cart": {
|
||||
"id": "id_SE0IrhFUnQnFNLiQqe",
|
||||
"payment_collection": {
|
||||
"id": "id_YhuROrBan2lyBmDB1M",
|
||||
"currency_code": "{value}",
|
||||
"region_id": "{value}",
|
||||
"amount": {
|
||||
"numeric": 9
|
||||
},
|
||||
"status": "not_paid",
|
||||
"payment_providers": [{
|
||||
"id": "id_NpxxM0ouevvB1c",
|
||||
"is_enabled": true
|
||||
}]
|
||||
}
|
||||
},
|
||||
"item_tax_lines": [{
|
||||
"rate": 48,
|
||||
"code": {},
|
||||
"name": "Vernon",
|
||||
"provider_id": "{value}",
|
||||
"line_item_id": "{value}"
|
||||
}],
|
||||
"shipping_tax_lines": [{
|
||||
"rate": 49,
|
||||
"code": {},
|
||||
"name": "Jasen",
|
||||
"provider_id": "{value}",
|
||||
"shipping_line_id": "{value}"
|
||||
}]
|
||||
})
|
||||
}
|
||||
)
|
||||
You can use the [retrieveCartStep](../core_flows.Cart.Steps_Cart.retrieveCartStep/page.mdx) to retrieve a cart's details.
|
||||
|
||||
:::
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
const data = setTaxLinesForItemsStep({
|
||||
// retrieve the details of the cart from another workflow
|
||||
// or in another step using the Cart Module's service
|
||||
cart,
|
||||
"item_tax_lines": [{
|
||||
"rate": 48,
|
||||
"code": "CODE123",
|
||||
"name": "Tax rate 2",
|
||||
"provider_id": "provider_1",
|
||||
"line_item_id": "litem_123"
|
||||
}],
|
||||
"shipping_tax_lines": [{
|
||||
"rate": 49,
|
||||
"code": "CODE456",
|
||||
"name": "Tax rate 1",
|
||||
"provider_id": "provider_1",
|
||||
"shipping_line_id": "sm_123"
|
||||
}]
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"SetTaxLinesForItemsStepInput","type":"[SetTaxLinesForItemsStepInput](../../../../interfaces/core_flows.SetTaxLinesForItemsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"cart","type":"[CartWorkflowDTO](../../../../../types/interfaces/types.CartWorkflowDTO/page.mdx)","description":"The cart details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_collection","type":"[PaymentCollectionDTO](../../../../../payment/interfaces/payment.PaymentCollectionDTO/page.mdx)","description":"The payment collection details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The ISO 3 character currency code of the payment sessions and payments associated with payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"The id of the associated region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberValue](../../../../../payment/types/payment.BigNumberValue/page.mdx)","description":"The total amount to be authorized and captured.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PaymentCollectionStatus](../../../../../payment/types/payment.PaymentCollectionStatus/page.mdx)","description":"The status of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_providers","type":"[PaymentProviderDTO](../../../../../payment/interfaces/payment.PaymentProviderDTO/page.mdx)[]","description":"The payment provider used to process the associated payment sessions and payments.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"authorized_amount","type":"[BigNumberValue](../../../../../payment/types/payment.BigNumberValue/page.mdx)","description":"The amount authorized within the associated payment sessions.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"refunded_amount","type":"[BigNumberValue](../../../../../payment/types/payment.BigNumberValue/page.mdx)","description":"The amount refunded within the associated payments.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"captured_amount","type":"[BigNumberValue](../../../../../payment/types/payment.BigNumberValue/page.mdx)","description":"The amount captured within the associated payments.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"completed_at","type":"`string` \\| `Date`","description":"When the payment collection was completed.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the payment collection was created.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the payment collection was updated.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_sessions","type":"[PaymentSessionDTO](../../../../../payment/interfaces/payment.PaymentSessionDTO/page.mdx)[]","description":"The associated payment sessions.","optional":true,"defaultValue":"","expandable":true,"children":[]},{"name":"payments","type":"[PaymentDTO](../../../../../payment/interfaces/payment.PaymentDTO/page.mdx)[]","description":"The associated payments.","optional":true,"defaultValue":"","expandable":true,"children":[]}]},{"name":"customer","type":"[CustomerDTO](../../../../../customer/interfaces/customer.CustomerDTO/page.mdx)","description":"The customer details.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"The email of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"A flag indicating if customer has an account or not.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"default_billing_address_id","type":"`null` \\| `string`","description":"The associated default billing address's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"default_shipping_address_iLine truncated
|
||||
<TypeList types={[{"name":"SetTaxLinesForItemsStepInput","type":"[SetTaxLinesForItemsStepInput](../../../../interfaces/core_flows.SetTaxLinesForItemsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"cart","type":"[CartWorkflowDTO](../../../../../types/interfaces/types.CartWorkflowDTO/page.mdx)","description":"The cart's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_collection","type":"[PaymentCollectionDTO](../../../../../payment/interfaces/payment.PaymentCollectionDTO/page.mdx)","description":"The payment collection details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The ISO 3 character currency code of the payment sessions and payments associated with payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"The id of the associated region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberValue](../../../../../payment/types/payment.BigNumberValue/page.mdx)","description":"The total amount to be authorized and captured.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PaymentCollectionStatus](../../../../../payment/types/payment.PaymentCollectionStatus/page.mdx)","description":"The status of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_providers","type":"[PaymentProviderDTO](../../../../../payment/interfaces/payment.PaymentProviderDTO/page.mdx)[]","description":"The payment provider used to process the associated payment sessions and payments.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"authorized_amount","type":"[BigNumberValue](../../../../../payment/types/payment.BigNumberValue/page.mdx)","description":"The amount authorized within the associated payment sessions.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"refunded_amount","type":"[BigNumberValue](../../../../../payment/types/payment.BigNumberValue/page.mdx)","description":"The amount refunded within the associated payments.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"captured_amount","type":"[BigNumberValue](../../../../../payment/types/payment.BigNumberValue/page.mdx)","description":"The amount captured within the associated payments.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"completed_at","type":"`string` \\| `Date`","description":"When the payment collection was completed.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the payment collection was created.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the payment collection was updated.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_sessions","type":"[PaymentSessionDTO](../../../../../payment/interfaces/payment.PaymentSessionDTO/page.mdx)[]","description":"The associated payment sessions.","optional":true,"defaultValue":"","expandable":true,"children":[]},{"name":"payments","type":"[PaymentDTO](../../../../../payment/interfaces/payment.PaymentDTO/page.mdx)[]","description":"The associated payments.","optional":true,"defaultValue":"","expandable":true,"children":[]}]},{"name":"customer","type":"[CustomerDTO](../../../../../customer/interfaces/customer.CustomerDTO/page.mdx)","description":"The customer details.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"The email of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"A flag indicating if customer has an account or not.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"default_billing_address_id","type":"`null` \\| `string`","description":"The associated default billing address's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"default_shipping_addressLine truncated
|
||||
+2
-2
@@ -24,7 +24,7 @@ const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = updateCartPromotionsStep({
|
||||
"id": "id_FMMyyyKUjF2KjYp"
|
||||
"id": "id_Bpdp4Tz35m"
|
||||
})
|
||||
}
|
||||
)
|
||||
@@ -33,4 +33,4 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"UpdateCartPromotionStepInput","type":"[UpdateCartPromotionStepInput](../../../../interfaces/core_flows.UpdateCartPromotionStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"promo_codes","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"action","type":"[ADD](../../../../../utils/PromotionUtils/enums/utils.PromotionUtils.PromotionActions/page.mdx#add) \\| [REMOVE](../../../../../utils/PromotionUtils/enums/utils.PromotionUtils.PromotionActions/page.mdx#remove) \\| [REPLACE](../../../../../utils/PromotionUtils/enums/utils.PromotionUtils.PromotionActions/page.mdx#replace)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="updateCartPromotionsStep"/>
|
||||
<TypeList types={[{"name":"UpdateCartPromotionStepInput","type":"[UpdateCartPromotionStepInput](../../../../interfaces/core_flows.UpdateCartPromotionStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart to update promotions for.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"promo_codes","type":"`string`[]","description":"The promotion codes to apply on the cart.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"action","type":"[ADD](../../../../../utils/PromotionUtils/enums/utils.PromotionUtils.PromotionActions/page.mdx#add) \\| [REMOVE](../../../../../utils/PromotionUtils/enums/utils.PromotionUtils.PromotionActions/page.mdx#remove) \\| [REPLACE](../../../../../utils/PromotionUtils/enums/utils.PromotionUtils.PromotionActions/page.mdx#replace)","description":"Whether to add, remove, or replace promotion codes.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="updateCartPromotionsStep"/>
|
||||
+7
-13
@@ -14,24 +14,18 @@ This documentation provides a reference to the `updateCartsStep`. It belongs to
|
||||
|
||||
This step updates a cart.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { updateCartsStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = updateCartsStep([{
|
||||
"id": "id_6MzWGTzXtywkrtb"
|
||||
}])
|
||||
}
|
||||
)
|
||||
```ts
|
||||
const data = updateCartsStep([{
|
||||
id: "cart_123",
|
||||
email: "customer@gmail.com",
|
||||
}])
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"UpdateCartWorkflowInputDTO[]","type":"[UpdateCartWorkflowInputDTO](../../../../../types/interfaces/types.UpdateCartWorkflowInputDTO/page.mdx)[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"UpdateCartWorkflowInputDTO","type":"[UpdateCartWorkflowInputDTO](../../../../../types/interfaces/types.UpdateCartWorkflowInputDTO/page.mdx)","optional":false,"defaultValue":"","description":"The details to update in a cart.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart to update.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"promo_codes","type":"`string`[]","description":"An array of promotional codes applied on the cart.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"The ID of the cart's region.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"`null` \\| `string`","description":"The ID of the cart's customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`null` \\| `string`","description":"The ID of the cart's sales channel.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"The email address of the cart's customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency code for the cart.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Custom key-value pairs of data related to the cart.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"`null` \\| [UpdateAddressDTO](../../../../../cart/interfaces/cart.UpdateAddressDTO/page.mdx) \\| [CreateAddressDTO](../../../../../cart/interfaces/cart.CreateAddressDTO/page.mdx)","description":"The cart's shipping address. You can either update the cart's existing shipping address, or create a new one.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"The associated customer's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`string`","description":"The company of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`string`","description":"The first name of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`string`","description":"The last name of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`string`","description":"The first line of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`string`","description":"The second line of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`string`","description":"The city of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"The ISO two country code of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`string`","description":"The province of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`string`","description":"The postal code of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`string`","description":"The phone of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"billing_address","type":"`null` \\| [UpdateAddressDTO](../../../../../cart/interfaces/cart.UpdateAddressDTO/page.mdx) \\| [CreateAddressDTO](../../../../../cart/interfaces/cart.CreateAddressDTO/page.mdx)","description":"The cart's billing address. You can either update the cart's existing billing address, or create a new one.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"The associated customer's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`string`","descLine truncated
|
||||
<TypeList types={[{"name":"UpdateCartsStepInput","type":"[UpdateCartsStepInput](../../../../types/core_flows.UpdateCartsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart to update.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"promo_codes","type":"`string`[]","description":"An array of promotional codes applied on the cart.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"The ID of the cart's region.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"`null` \\| `string`","description":"The ID of the cart's customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`null` \\| `string`","description":"The ID of the cart's sales channel.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"The email address of the cart's customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency code for the cart.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Custom key-value pairs of data related to the cart.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"`null` \\| [UpdateAddressDTO](../../../../../cart/interfaces/cart.UpdateAddressDTO/page.mdx) \\| [CreateAddressDTO](../../../../../cart/interfaces/cart.CreateAddressDTO/page.mdx)","description":"The cart's shipping address. You can either update the cart's existing shipping address, or create a new one.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"The associated customer's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`string`","description":"The company of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`string`","description":"The first name of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`string`","description":"The last name of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`string`","description":"The first line of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`string`","description":"The second line of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`string`","description":"The city of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"The ISO two country code of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`string`","description":"The province of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`string`","description":"The postal code of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`string`","description":"The phone of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"billing_address","type":"`null` \\| [UpdateAddressDTO](../../../../../cart/interfaces/cart.UpdateAddressDTO/page.mdx) \\| [CreateAddressDTO](../../../../../cart/interfaces/cart.CreateAddressDTO/page.mdx)","description":"The cart's billing address. You can either update the cart's existing billing address, or create a new one.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"The associated customer's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`string`","description":"The company of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`string`","description":"The first name of the address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`stringLine truncated
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+16
-17
@@ -14,28 +14,27 @@ This documentation provides a reference to the `updateLineItemsStep`. It belongs
|
||||
|
||||
This step updates a cart's line items.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { updateLineItemsStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = updateLineItemsStep({
|
||||
"id": "id_Luh6C6I3Rle6E4j",
|
||||
"items": [{
|
||||
"selector": "{value}",
|
||||
"data": "{value}"
|
||||
}]
|
||||
})
|
||||
}
|
||||
)
|
||||
```ts
|
||||
const data = updateLineItemsStep({
|
||||
id: "cart_123",
|
||||
items: [
|
||||
{
|
||||
selector: {
|
||||
id: "line_item_123"
|
||||
},
|
||||
data: {
|
||||
quantity: 2
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"UpdateLineItemsStepInput","type":"[UpdateLineItemsStepInput](../../../../interfaces/core_flows.UpdateLineItemsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[UpdateLineItemWithSelectorDTO](../../../../../cart/interfaces/cart.UpdateLineItemWithSelectorDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"selector","type":"Partial<[CartLineItemDTO](../../../../../cart/interfaces/cart.CartLineItemDTO/page.mdx)>","description":"Filters to specify which line items to update.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"original_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original subtotal of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original tax total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item subtotal of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item tax total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The subtotal of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The tax total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The discount total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The discount tax total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_original_total","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"The raw original total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_original_subtotal","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"The raw original subtotal of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_original_tax_total","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"The raw original tax total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_item_total","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"The raw item total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_item_subtotal","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"The raw item subtotal of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_item_tax_total","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"The raw item tax total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_total","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"The raw Line truncated
|
||||
<TypeList types={[{"name":"UpdateLineItemsStepInput","type":"[UpdateLineItemsStepInput](../../../../interfaces/core_flows.UpdateLineItemsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart that the line items belong to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[UpdateLineItemWithSelectorDTO](../../../../../cart/interfaces/cart.UpdateLineItemWithSelectorDTO/page.mdx)[]","description":"The line items to update.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"selector","type":"Partial<[CartLineItemDTO](../../../../../cart/interfaces/cart.CartLineItemDTO/page.mdx)>","description":"Filters to specify which line items to update.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"original_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original subtotal of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original tax total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item subtotal of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item tax total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The subtotal of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The tax total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The discount total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The discount tax total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_original_total","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"The raw original total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_original_subtotal","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"The raw original subtotal of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_original_tax_total","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"The raw original tax total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_item_total","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"The raw item total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_item_subtotal","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"The raw item subtotal of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_item_tax_total","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"The raw item tax total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_total","type":"[BigNumberRawValue](../../../Line truncated
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
---
|
||||
slug: /references/medusa-workflows/steps/updateShippingMethodsStep
|
||||
sidebar_label: updateShippingMethodsStep
|
||||
tags:
|
||||
- cart
|
||||
- step
|
||||
---
|
||||
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
# updateShippingMethodsStep - Medusa Core Workflows Reference
|
||||
|
||||
This documentation provides a reference to the `updateShippingMethodsStep`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This step updates a cart's shipping methods.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
const data = updateOrderShippingMethodsStep([
|
||||
{
|
||||
id: "sm_123",
|
||||
amount: 10
|
||||
}
|
||||
])
|
||||
```
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"UpdateShippingMethodsStepInput","type":"[UpdateShippingMethodsStepInput](../../../../types/core_flows.UpdateShippingMethodsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the shipping method.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the shipping method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The amount of the shipping method.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"is_tax_inclusive","type":"`boolean`","description":"The tax inclusivity setting of the shipping method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`Record<string, unknown>`","description":"The data of the shipping method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_lines","type":"[CreateTaxLineDTO](../../../../../cart/interfaces/cart.CreateTaxLineDTO/page.mdx)[] \\| [UpdateTaxLineDTO](../../../../../cart/interfaces/cart.UpdateTaxLineDTO/page.mdx)[]","description":"The tax lines of the shipping method.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the tax line.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rate","type":"`number`","description":"The rate of the tax line.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"The ID of the tax line.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the tax line.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate_id","type":"`string`","description":"The associated tax rate's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The associated provider's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"item_id","type":"`string`","description":"The associated item's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"adjustments","type":"[CreateAdjustmentDTO](../../../../../cart/interfaces/cart.CreateAdjustmentDTO/page.mdx)[] \\| [UpdateAdjustmentDTO](../../../../../cart/interfaces/cart.UpdateAdjustmentDTO/page.mdx)[]","description":"The adjustments of the shipping method.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the promotion that lead to\nthis adjustment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The amount to adjust the original amount with.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"id","type":"`string`","description":"The ID of the adjustment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the adjustment.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"promotion_id","type":"`string`","description":"The associated promotion's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"Line truncated
|
||||
|
||||
## Output
|
||||
|
||||
<TypeList types={[{"name":"CartShippingMethodDTO[]","type":"[CartShippingMethodDTO](../../../../../cart/interfaces/cart.CartShippingMethodDTO/page.mdx)[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"CartShippingMethodDTO","type":"[CartShippingMethodDTO](../../../../../cart/interfaces/cart.CartShippingMethodDTO/page.mdx)","optional":false,"defaultValue":"","description":"The cart shipping method details.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the shipping method.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`string`","description":"The ID of the associated cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the shipping method.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The price of the shipping method.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"is_tax_inclusive","type":"`boolean`","description":"Whether the shipping method price is tax inclusive.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the shipping method was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the shipping method was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original total of the cart shipping method.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original subtotal of the cart shipping method.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original tax total of the cart shipping method.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The total of the cart shipping method.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The subtotal of the cart shipping method.","optional":false,"defaultValueLine truncated
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
---
|
||||
slug: /references/medusa-workflows/steps/validateAndReturnShippingMethodsDataStep
|
||||
sidebar_label: validateAndReturnShippingMethodsDataStep
|
||||
tags:
|
||||
- fulfillment
|
||||
- step
|
||||
---
|
||||
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
# validateAndReturnShippingMethodsDataStep - Medusa Core Workflows Reference
|
||||
|
||||
This documentation provides a reference to the `validateAndReturnShippingMethodsDataStep`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This step validates shipping options to ensure they can be applied on a cart.
|
||||
The step either returns the validated data or void.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
const data = validateAndReturnShippingMethodsDataStep({
|
||||
id: "sm_123",
|
||||
provider_id: "my_provider",
|
||||
option_data: {},
|
||||
method_data: {},
|
||||
context: {
|
||||
id: "cart_123",
|
||||
shipping_address: {
|
||||
id: "saddr_123",
|
||||
first_name: "Jane",
|
||||
last_name: "Smith",
|
||||
address_1: "456 Elm St",
|
||||
city: "Shelbyville",
|
||||
country_code: "us",
|
||||
postal_code: "67890",
|
||||
},
|
||||
items: [
|
||||
{
|
||||
variant: {
|
||||
id: "variant_123",
|
||||
weight: 1,
|
||||
length: 1,
|
||||
height: 1,
|
||||
width: 1,
|
||||
material: "wood",
|
||||
product: {
|
||||
id: "prod_123"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
product: {
|
||||
id: "prod_123",
|
||||
collection_id: "pcol_123",
|
||||
categories: [],
|
||||
tags: []
|
||||
},
|
||||
from_location: {
|
||||
id: "sloc_123",
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
address_1: "123 Main St",
|
||||
city: "Springfield",
|
||||
country_code: "us",
|
||||
postal_code: "12345",
|
||||
},
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"ValidateShippingMethodsDataInput","type":"[ValidateShippingMethodsDataInput](../../../../types/core_flows.ValidateShippingMethodsDataInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The shipping method's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The fulfillment provider ID that associated with the shipping option\nthat the method was created from.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"option_data","type":"`Record<string, unknown>`","description":"The `data` property of the shipping option that the shipping method was \ncreated from.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"method_data","type":"`Record<string, unknown>`","description":"The `data` property of the shipping method.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"context","type":"[ValidateFulfillmentDataContext](../../../../../fulfillment/types/fulfillment.ValidateFulfillmentDataContext/page.mdx)","description":"The context to validate the shipping method.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"[CartDTO](../../../../../fulfillment/interfaces/fulfillment.CartDTO/page.mdx)[`\"id\"`]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"[CartDTO](../../../../../fulfillment/interfaces/fulfillment.CartDTO/page.mdx)[`\"shipping_address\"`]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[CartDTO](../../../../../fulfillment/interfaces/fulfillment.CartDTO/page.mdx)[`\"items\"`] & `object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"variant","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"from_location","type":"[StockLocationDTO](../../../../../fulfillment/types/fulfillment.StockLocationDTO/page.mdx)","description":"Details about the location that items are being shipped from.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>` \\| `null`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_id","type":"`string`","description":"The associated address's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_sets","type":"[FulfillmentSetDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentSetDTO/page.mdx)[]","description":"Fulfillment sets for the location","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The creation date of the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The update date of the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date` \\| `null`","description":"The deletion date of the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address","type":"[StockLocationAddressDTO](../../../../../fulfillment/types/fulfillment.StockLocationAddressDTO/page.mdx)","description":"The address of the stock location.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validateAndReturnShippingMethodsDataStep"/>
|
||||
|
||||
## Output
|
||||
|
||||
<TypeList types={[{"name":"object[]","type":"`object`[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validateAndReturnShippingMethodsDataStep"/>
|
||||
+15
-29
@@ -12,41 +12,27 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
This documentation provides a reference to the `validateCartPaymentsStep`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This step validates a cart's payment sessions. Their status must
|
||||
be `pending` or `requires_more`.
|
||||
be `pending` or `requires_more`. If not valid, the step throws an error.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { validateCartPaymentsStep } from "@medusajs/medusa/core-flows"
|
||||
:::tip
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = validateCartPaymentsStep({
|
||||
"cart": {
|
||||
"id": "id_48kB6S6mQoqDPvLilUfK",
|
||||
"payment_collection": {
|
||||
"id": "id_vj9fGZtJOqtMGdubl",
|
||||
"currency_code": "{value}",
|
||||
"region_id": "{value}",
|
||||
"amount": {
|
||||
"numeric": 40
|
||||
},
|
||||
"status": "not_paid",
|
||||
"payment_providers": [{
|
||||
"id": "id_QBTxhwnkN4f0ULXVv",
|
||||
"is_enabled": false
|
||||
}]
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
You can use the [retrieveCartStep](../core_flows.Cart.Steps_Cart.retrieveCartStep/page.mdx) to retrieve a cart's details.
|
||||
|
||||
:::
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
const data = validateCartPaymentsStep({
|
||||
// retrieve the details of the cart from another workflow
|
||||
// or in another step using the Cart Module's service
|
||||
cart
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"ValidateCartPaymentsStepInput","type":"[ValidateCartPaymentsStepInput](../../../../interfaces/core_flows.ValidateCartPaymentsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"cart","type":"[CartWorkflowDTO](../../../../../types/interfaces/types.CartWorkflowDTO/page.mdx)","description":"The cart details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_collection","type":"[PaymentCollectionDTO](../../../../../payment/interfaces/payment.PaymentCollectionDTO/page.mdx)","description":"The payment collection details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The ISO 3 character currency code of the payment sessions and payments associated with payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"The id of the associated region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberValue](../../../../../payment/types/payment.BigNumberValue/page.mdx)","description":"The total amount to be authorized and captured.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PaymentCollectionStatus](../../../../../payment/types/payment.PaymentCollectionStatus/page.mdx)","description":"The status of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_providers","type":"[PaymentProviderDTO](../../../../../payment/interfaces/payment.PaymentProviderDTO/page.mdx)[]","description":"The payment provider used to process the associated payment sessions and payments.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"authorized_amount","type":"[BigNumberValue](../../../../../payment/types/payment.BigNumberValue/page.mdx)","description":"The amount authorized within the associated payment sessions.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"refunded_amount","type":"[BigNumberValue](../../../../../payment/types/payment.BigNumberValue/page.mdx)","description":"The amount refunded within the associated payments.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"captured_amount","type":"[BigNumberValue](../../../../../payment/types/payment.BigNumberValue/page.mdx)","description":"The amount captured within the associated payments.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"completed_at","type":"`string` \\| `Date`","description":"When the payment collection was completed.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the payment collection was created.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the payment collection was updated.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_sessions","type":"[PaymentSessionDTO](../../../../../payment/interfaces/payment.PaymentSessionDTO/page.mdx)[]","description":"The associated payment sessions.","optional":true,"defaultValue":"","expandable":true,"children":[]},{"name":"payments","type":"[PaymentDTO](../../../../../payment/interfaces/payment.PaymentDTO/page.mdx)[]","description":"The associated payments.","optional":true,"defaultValue":"","expandable":true,"children":[]}]},{"name":"customer","type":"[CustomerDTO](../../../../../customer/interfaces/customer.CustomerDTO/page.mdx)","description":"The customer details.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"The email of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"A flag indicating if customer has an account or not.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"default_billing_address_id","type":"`null` \\| `string`","description":"The associated default billing address's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"default_shipping_addresLine truncated
|
||||
<TypeList types={[{"name":"ValidateCartPaymentsStepInput","type":"[ValidateCartPaymentsStepInput](../../../../interfaces/core_flows.ValidateCartPaymentsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"cart","type":"[CartWorkflowDTO](../../../../../types/interfaces/types.CartWorkflowDTO/page.mdx)","description":"The cart to validate payment sessions for.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_collection","type":"[PaymentCollectionDTO](../../../../../payment/interfaces/payment.PaymentCollectionDTO/page.mdx)","description":"The payment collection details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The ISO 3 character currency code of the payment sessions and payments associated with payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"The id of the associated region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"[BigNumberValue](../../../../../payment/types/payment.BigNumberValue/page.mdx)","description":"The total amount to be authorized and captured.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PaymentCollectionStatus](../../../../../payment/types/payment.PaymentCollectionStatus/page.mdx)","description":"The status of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_providers","type":"[PaymentProviderDTO](../../../../../payment/interfaces/payment.PaymentProviderDTO/page.mdx)[]","description":"The payment provider used to process the associated payment sessions and payments.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"authorized_amount","type":"[BigNumberValue](../../../../../payment/types/payment.BigNumberValue/page.mdx)","description":"The amount authorized within the associated payment sessions.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"refunded_amount","type":"[BigNumberValue](../../../../../payment/types/payment.BigNumberValue/page.mdx)","description":"The amount refunded within the associated payments.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"captured_amount","type":"[BigNumberValue](../../../../../payment/types/payment.BigNumberValue/page.mdx)","description":"The amount captured within the associated payments.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"completed_at","type":"`string` \\| `Date`","description":"When the payment collection was completed.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the payment collection was created.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the payment collection was updated.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_sessions","type":"[PaymentSessionDTO](../../../../../payment/interfaces/payment.PaymentSessionDTO/page.mdx)[]","description":"The associated payment sessions.","optional":true,"defaultValue":"","expandable":true,"children":[]},{"name":"payments","type":"[PaymentDTO](../../../../../payment/interfaces/payment.PaymentDTO/page.mdx)[]","description":"The associated payments.","optional":true,"defaultValue":"","expandable":true,"children":[]}]},{"name":"customer","type":"[CustomerDTO](../../../../../customer/interfaces/customer.CustomerDTO/page.mdx)","description":"The customer details.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"The email of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"A flag indicating if customer has an account or not.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"default_billing_address_id","type":"`null` \\| `string`","description":"The associated default billing address's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name"Line truncated
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
---
|
||||
slug: /references/medusa-workflows/steps/validateCartShippingOptionsPriceStep
|
||||
sidebar_label: validateCartShippingOptionsPriceStep
|
||||
tags:
|
||||
- step
|
||||
---
|
||||
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
# validateCartShippingOptionsPriceStep - Medusa Core Workflows Reference
|
||||
|
||||
This documentation provides a reference to the `validateCartShippingOptionsPriceStep`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This step validates shipping options to ensure they have a price.
|
||||
If not valid, the step throws an error.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
const data = validateCartShippingOptionsPriceStep({
|
||||
shippingOptions: [
|
||||
{
|
||||
id: "so_123",
|
||||
},
|
||||
{
|
||||
id: "so_321",
|
||||
calculated_price: {
|
||||
calculated_amount: 10,
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"ValidateCartShippingOptionsPriceInput","type":"[ValidateCartShippingOptionsPriceInput](../../../../types/core_flows.ValidateCartShippingOptionsPriceInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"shippingOptions","type":"`any`[]","description":"The shipping option's details. Should have a `calculated_price.calculated_amount`\nto be considered valid.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validateCartShippingOptionsPriceStep"/>
|
||||
+11
-152
@@ -13,161 +13,20 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
This documentation provides a reference to the `validateCartShippingOptionsStep`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This step validates shipping options to ensure they can be applied on a cart.
|
||||
If not valid, the step throws an error.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { validateCartShippingOptionsStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = validateCartShippingOptionsStep({
|
||||
"cart": {
|
||||
"id": "id_1WDBYIkJWevCocwcdK",
|
||||
"currency_code": "{value}",
|
||||
"original_item_total": {
|
||||
"numeric": 26
|
||||
},
|
||||
"original_item_subtotal": {
|
||||
"numeric": 8
|
||||
},
|
||||
"original_item_tax_total": {
|
||||
"numeric": 3
|
||||
},
|
||||
"item_total": {
|
||||
"numeric": 34
|
||||
},
|
||||
"item_subtotal": {
|
||||
"numeric": 19
|
||||
},
|
||||
"item_tax_total": {
|
||||
"numeric": 50
|
||||
},
|
||||
"original_total": {
|
||||
"numeric": 21
|
||||
},
|
||||
"original_subtotal": {
|
||||
"numeric": 38
|
||||
},
|
||||
"original_tax_total": {
|
||||
"numeric": 50
|
||||
},
|
||||
"total": {
|
||||
"numeric": 17
|
||||
},
|
||||
"subtotal": {
|
||||
"numeric": 29
|
||||
},
|
||||
"tax_total": {
|
||||
"numeric": 22
|
||||
},
|
||||
"discount_total": {
|
||||
"numeric": 42
|
||||
},
|
||||
"discount_tax_total": {
|
||||
"numeric": 1
|
||||
},
|
||||
"gift_card_total": {
|
||||
"numeric": 4
|
||||
},
|
||||
"gift_card_tax_total": {
|
||||
"numeric": 41
|
||||
},
|
||||
"shipping_total": {
|
||||
"numeric": 19
|
||||
},
|
||||
"shipping_subtotal": {
|
||||
"numeric": 43
|
||||
},
|
||||
"shipping_tax_total": {
|
||||
"numeric": 34
|
||||
},
|
||||
"original_shipping_total": {
|
||||
"numeric": 4
|
||||
},
|
||||
"original_shipping_subtotal": {
|
||||
"numeric": 47
|
||||
},
|
||||
"original_shipping_tax_total": {
|
||||
"numeric": 42
|
||||
},
|
||||
"raw_original_item_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_item_subtotal": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_item_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_item_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_item_subtotal": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_item_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_subtotal": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_subtotal": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_discount_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_discount_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_gift_card_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_gift_card_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_shipping_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_shipping_subtotal": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_shipping_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_shipping_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_shipping_subtotal": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_shipping_tax_total": {
|
||||
"value": "{value}"
|
||||
}
|
||||
},
|
||||
"shippingOptionsContext": {},
|
||||
"option_ids": [
|
||||
"{value}"
|
||||
]
|
||||
})
|
||||
}
|
||||
)
|
||||
```ts
|
||||
const data = validateCartShippingOptionsStep({
|
||||
// retrieve the details of the cart from another workflow
|
||||
// or in another step using the Cart Module's service
|
||||
cart,
|
||||
option_ids: ["so_123"],
|
||||
shippingOptionsContext: {}
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"ValidateCartShippingOptionsStepInput","type":"[ValidateCartShippingOptionsStepInput](../../../../interfaces/core_flows.ValidateCartShippingOptionsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"cart","type":"[CartDTO](../../../../../cart/interfaces/cart.CartDTO/page.mdx)","description":"The cart details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the cart","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_item_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item subtotal of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_item_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item tax total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item subtotal of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item tax total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","descriLine truncated
|
||||
<TypeList types={[{"name":"ValidateCartShippingOptionsStepInput","type":"[ValidateCartShippingOptionsStepInput](../../../../interfaces/core_flows.ValidateCartShippingOptionsStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"cart","type":"[CartDTO](../../../../../cart/interfaces/cart.CartDTO/page.mdx)","description":"The cart to validate shipping options for.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the cart","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_item_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item subtotal of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_item_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item tax total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item subtotal of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item tax total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric",Line truncated
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
---
|
||||
slug: /references/medusa-workflows/steps/validateCartStep
|
||||
sidebar_label: validateCartStep
|
||||
tags:
|
||||
- step
|
||||
---
|
||||
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
# validateCartStep - Medusa Core Workflows Reference
|
||||
|
||||
This documentation provides a reference to the `validateCartStep`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This step validates a cart to ensure it exists and is not completed.
|
||||
If not valid, the step throws an error.
|
||||
|
||||
:::tip
|
||||
|
||||
You can use the [retrieveCartStep](../core_flows.Cart.Steps_Cart.retrieveCartStep/page.mdx) to retrieve a cart's details.
|
||||
|
||||
:::
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
const data = validateCartStep({
|
||||
// retrieve the details of the cart from another workflow
|
||||
// or in another step using the Cart Module's service
|
||||
cart,
|
||||
})
|
||||
```
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"ValidateCartStepInput","type":"[ValidateCartStepInput](../../../../interfaces/core_flows.ValidateCartStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"cart","type":"[CartDTO](../../../../../cart/interfaces/cart.CartDTO/page.mdx) \\| [CartWorkflowDTO](../../../../../types/interfaces/types.CartWorkflowDTO/page.mdx)","description":"The cart to validate.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the cart","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_item_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item subtotal of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_item_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item tax total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item subtotal of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item tax total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original total of the cart.","optional":false,"defaultValue":"","expandable":false,"children"Line truncated
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
---
|
||||
slug: /references/medusa-workflows/steps/validateLineItemPricesStep
|
||||
sidebar_label: validateLineItemPricesStep
|
||||
tags:
|
||||
- step
|
||||
---
|
||||
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
# validateLineItemPricesStep - Medusa Core Workflows Reference
|
||||
|
||||
This documentation provides a reference to the `validateLineItemPricesStep`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This step validates the specified line item objects to ensure they have prices.
|
||||
If an item doesn't have a price, the step throws an error.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
const data = validateLineItemPricesStep({
|
||||
items: [
|
||||
{
|
||||
unit_price: 10,
|
||||
title: "Shirt"
|
||||
},
|
||||
{
|
||||
title: "Pants"
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"ValidateLineItemPricesStepInput","type":"[ValidateLineItemPricesStepInput](../../../../interfaces/core_flows.ValidateLineItemPricesStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"items","type":"`object`[]","description":"The line items to validate.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"unit_price","type":"`null` \\| `number`","description":"The price of the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validateLineItemPricesStep"/>
|
||||
+17
-15
@@ -12,24 +12,26 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
This documentation provides a reference to the `validateVariantPricesStep`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This step validates the specified variant objects to ensure they have prices.
|
||||
If not valid, the step throws an error.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { validateVariantPricesStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = validateVariantPricesStep({
|
||||
"variants": [{
|
||||
"id": "id_c7o56DosdFnI"
|
||||
}]
|
||||
})
|
||||
}
|
||||
)
|
||||
```ts
|
||||
const data = validateVariantPricesStep({
|
||||
variants: [
|
||||
{
|
||||
id: "variant_123",
|
||||
},
|
||||
{
|
||||
id: "variant_321",
|
||||
calculated_price: {
|
||||
calculated_amount: 10,
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"ValidateVariantPricesStepInput","type":"[ValidateVariantPricesStepInput](../../../../interfaces/core_flows.ValidateVariantPricesStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"variants","type":"`object`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"calculated_price","type":"`object`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"calculated_amount","type":"`null` \\| [BigNumberInput](../../../../../types/types/types.BigNumberInput/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validateVariantPricesStep"/>
|
||||
<TypeList types={[{"name":"ValidateVariantPricesStepInput","type":"[ValidateVariantPricesStepInput](../../../../interfaces/core_flows.ValidateVariantPricesStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"variants","type":"`object`[]","description":"The variants to validate.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"calculated_price","type":"`object`","description":"The calculated price of the variant.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"calculated_amount","type":"`null` \\| [BigNumberInput](../../../../../types/types/types.BigNumberInput/page.mdx)","description":"The calculated amount of the price.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validateVariantPricesStep"/>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
# updateShippingMethodsStepId
|
||||
|
||||
`Const` **updateShippingMethodsStepId**: `"update-shipping-methods-step"`
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
# validateAndReturnShippingMethodsDataStepId
|
||||
|
||||
`Const` **validateAndReturnShippingMethodsDataStepId**: `"validate-and-return-shipping-methods-data"`
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
# validateCartShippingOptionsPriceStepId
|
||||
|
||||
`Const` **validateCartShippingOptionsPriceStepId**: `"validate-cart-shipping-options"`
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
# validateCartStepId
|
||||
|
||||
`Const` **validateCartStepId**: `"validate-cart"`
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
# validateLineItemPricesStepId
|
||||
|
||||
`Const` **validateLineItemPricesStepId**: `"validate-line-item-prices"`
|
||||
+88
-20
@@ -8,6 +8,11 @@ tags:
|
||||
- event bus
|
||||
- workflow
|
||||
- query
|
||||
- tax
|
||||
- promotion
|
||||
- link
|
||||
- payment
|
||||
- logger
|
||||
---
|
||||
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
@@ -16,9 +21,12 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `addShippingMethodToCartWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow adds shipping methods to a cart.
|
||||
This workflow adds a shipping method to a cart. It's executed by the
|
||||
[Add Shipping Method Store API Route](https://docs.medusajs.com/api/store#carts\_postcartsidshippingmethods).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/cart/workflows/add-shipping-method-to-cart.ts#L34" />
|
||||
You can use this workflow within your own customizations or custom workflows, allowing you to wrap custom logic around adding a shipping method to the cart.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/cart/workflows/add-shipping-method-to-cart.ts#L81" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -39,10 +47,17 @@ export async function POST(
|
||||
const { result } = await addShippingMethodToCartWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}",
|
||||
"options": [{
|
||||
"id": "id_qChCECxNY9vE"
|
||||
}]
|
||||
cart_id: "cart_123",
|
||||
options: [{
|
||||
id: "so_123",
|
||||
},
|
||||
{
|
||||
id: "so_124",
|
||||
data: {
|
||||
carrier_code: "fedex",
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -67,10 +82,17 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await addShippingMethodToCartWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}",
|
||||
"options": [{
|
||||
"id": "id_qChCECxNY9vE"
|
||||
}]
|
||||
cart_id: "cart_123",
|
||||
options: [{
|
||||
id: "so_123",
|
||||
},
|
||||
{
|
||||
id: "so_124",
|
||||
data: {
|
||||
carrier_code: "fedex",
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -95,10 +117,17 @@ export default async function myCustomJob(
|
||||
const { result } = await addShippingMethodToCartWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}",
|
||||
"options": [{
|
||||
"id": "id_qChCECxNY9vE"
|
||||
}]
|
||||
cart_id: "cart_123",
|
||||
options: [{
|
||||
id: "so_123",
|
||||
},
|
||||
{
|
||||
id: "so_124",
|
||||
data: {
|
||||
carrier_code: "fedex",
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -124,10 +153,17 @@ const myWorkflow = createWorkflow(
|
||||
const result = addShippingMethodToCartWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"cart_id": "{value}",
|
||||
"options": [{
|
||||
"id": "id_qChCECxNY9vE"
|
||||
}]
|
||||
cart_id: "cart_123",
|
||||
options: [{
|
||||
id: "so_123",
|
||||
},
|
||||
{
|
||||
id: "so_124",
|
||||
data: {
|
||||
carrier_code: "fedex",
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -139,8 +175,40 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"addShippingMethodToCartWorkflow","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":1},{"type":"step","name":"validateCartShippingOptionsStep","description":"This step validates shipping options to ensure they can be applied on a cart.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateCartShippingOptionsStep/page.mdx","depth":2},{"type":"workflow","name":"listShippingOptionsForCartWithPricingWorkflow","description":"This workflow lists the shipping options of a cart.\n\n","link":"../core_flows.Cart.Workflows_Cart.listShippingOptionsForCartWithPricingWorkflow/page.mdx","depth":3},{"type":"step","name":"removeShippingMethodFromCartStep","description":"This step removes shipping methods from a cart.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.removeShippingMethodFromCartStep/page.mdx","depth":4},{"type":"step","name":"addShippingMethodToCartStep","description":"This step adds shipping methods to a cart.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.addShippingMethodToCartStep/page.mdx","depth":4},{"type":"step","name":"emitEventStep","description":"Emit an event.\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":4}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"addShippingMethodToCartWorkflow","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":1},{"type":"step","name":"validateCartStep","description":"This step validates a cart to ensure it exists and is not completed.\nIf not valid, the step throws an error.\n\n:::tip\n\nYou can use the [retrieveCartStep](../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.retrieveCartStep/page.mdx) to retrieve a cart's details.\n\n:::","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateCartStep/page.mdx","depth":2},{"type":"hook","name":"validate","description":"This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.","link":"#validate","depth":3},{"type":"step","name":"validateCartShippingOptionsStep","description":"This step validates shipping options to ensure they can be applied on a cart.\nIf not valid, the step throws an error.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateCartShippingOptionsStep/page.mdx","depth":4},{"type":"workflow","name":"listShippingOptionsForCartWithPricingWorkflow","description":"This workflow lists shipping options that can be used during checkout for a cart. It also retrieves the prices\nof these shipping options, including calculated prices that may be retrieved from third-party providers.\n\nThis workflow is executed in other cart-related workflows, such as [addShippingMethodToCartWorkflow](./page.mdx) to retrieve the\nprice of the shipping method being added to the cart.\n\nYou can use this workflow within your own customizations or custom workflows, allowing you to retrieve the shipping options of a cart and their prices \nin your custom flows.","link":"../core_flows.Cart.Workflows_Cart.listShippingOptionsForCartWithPricingWorkflow/page.mdx","depth":5},{"type":"step","name":"validateCartShippingOptionsPriceStep","description":"This step validates shipping options to ensure they have a price.\nIf not valid, the step throws an error.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateCartShippingOptionsPriceStep/page.mdx","depth":6},{"type":"step","name":"validateAndReturnShippingMethodsDataStep","description":"This step validates shipping options to ensure they can be applied on a cart.\nThe step either returns the validated data or void.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateAndReturnShippingMethodsDataStep/page.mdx","depth":7},{"type":"step","name":"removeShippingMethodFromCartStep","description":"This step removes shipping methods from a cart.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.removeShippingMethodFromCartStep/page.mdx","depth":8},{"type":"step","name":"addShippingMethodToCartStep","description":"This step adds shipping methods to a cart.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.addShippingMethodToCartStep/page.mdx","depth":8},{"type":"step","name":"emitEventStep","description":"Emit an event.","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":8},{"type":"workflow","name":"refreshCartItemsWorkflow","description":"This workflow refreshes a cart to ensure its prices, promotion codes, taxes, and other details are applied correctly. It's useful\nafter making a chnge to a cart, such as after adding an item to the cart or adding a promotion code.\n\nThis workflow is used by other cart-related workflows, such as the [addToCartWorkflow](../core_flows.Cart.Workflows_Cart.addToCartWorkflow/page.mdx) after an item\nis added to the cart.\n\nYou can use this workflow within your own customizations or custom workflows, allowing you to refresh the cart after making updates to it in your\ncustom flows.","link":"../core_flows.Cart.Workflows_Cart.refreshCartItemsWorkflow/page.mdx","depth":9}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"AddShippingMethodToCartWorkflowInput","type":"[AddShippingMethodToCartWorkflowInput](../../../../interfaces/core_flows.AddShippingMethodToCartWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`object`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="addShippingMethodToCartWorkflow"/>
|
||||
<TypeList types={[{"name":"AddShippingMethodToCartWorkflowInput","type":"[AddShippingMethodToCartWorkflowInput](../../../../interfaces/core_flows.AddShippingMethodToCartWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"The data to add a shipping method to a cart.","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The ID of the cart to add the shipping method to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`object`[]","description":"The shipping options to create the shipping methods from and add to the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the shipping option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`Record<string, unknown>`","description":"Custom data useful for the fulfillment provider processing the shipping option or method.\n\nLearn more in [this documentation](https://docs.medusajs.com/resources/commerce-modules/fulfillment/shipping-option#data-property).","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="addShippingMethodToCartWorkflow"/>
|
||||
|
||||
## Output
|
||||
|
||||
<TypeList types={[{"name":"undefined","type":"`undefined`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"undefined","type":"`undefined`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="addShippingMethodToCartWorkflow"/>
|
||||
|
||||
## Hooks
|
||||
|
||||
Hooks allow you to inject custom functionalities into the workflow. You'll receive data from the workflow, as well as additional data sent through an HTTP request.
|
||||
|
||||
Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/workflow-hooks) and [Additional Data](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).
|
||||
|
||||
### validate
|
||||
|
||||
This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.
|
||||
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
import { addShippingMethodToCartWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
addShippingMethodToCartWorkflow.hooks.validate(
|
||||
(async ({ input, cart }, { container }) => {
|
||||
//TODO
|
||||
})
|
||||
)
|
||||
```
|
||||
|
||||
#### Input
|
||||
|
||||
Handlers consuming this hook accept the following input.
|
||||
|
||||
<TypeList types={[{"name":"input","type":"object","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[AddShippingMethodToCartWorkflowInput](../../../../interfaces/core_flows.AddShippingMethodToCartWorkflowInput/page.mdx)","description":"The data to add a shipping method to a cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The ID of the cart to add the shipping method to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`object`[]","description":"The shipping options to create the shipping methods from and add to the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"cart","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validate"/>
|
||||
+89
-19
@@ -8,6 +8,12 @@ tags:
|
||||
- event bus
|
||||
- workflow
|
||||
- inventory
|
||||
- fulfillment
|
||||
- tax
|
||||
- promotion
|
||||
- link
|
||||
- payment
|
||||
- logger
|
||||
---
|
||||
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
@@ -16,9 +22,13 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `addToCartWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow adds items to a cart.
|
||||
This workflow adds a product variant to a cart as a line item. It's executed by the
|
||||
[Add Line Item Store API Route](https://docs.medusajs.com/api/store#carts\_postcartsidlineitems).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/cart/workflows/add-to-cart.ts#L38" />
|
||||
You can use this workflow within your own customizations or custom workflows, allowing you to wrap custom logic around adding an item to the cart.
|
||||
For example, you can use this workflow to add a line item to the cart with a custom price.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/cart/workflows/add-to-cart.ts#L69" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -39,10 +49,17 @@ export async function POST(
|
||||
const { result } = await addToCartWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}",
|
||||
"items": [{
|
||||
"quantity": 25
|
||||
}]
|
||||
cart_id: "cart_123",
|
||||
items: [{
|
||||
variant_id: "variant_123",
|
||||
quantity: 1,
|
||||
},
|
||||
{
|
||||
variant_id: "variant_456",
|
||||
quantity: 1,
|
||||
unit_price: 20
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -67,10 +84,17 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await addToCartWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}",
|
||||
"items": [{
|
||||
"quantity": 25
|
||||
}]
|
||||
cart_id: "cart_123",
|
||||
items: [{
|
||||
variant_id: "variant_123",
|
||||
quantity: 1,
|
||||
},
|
||||
{
|
||||
variant_id: "variant_456",
|
||||
quantity: 1,
|
||||
unit_price: 20
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -95,10 +119,17 @@ export default async function myCustomJob(
|
||||
const { result } = await addToCartWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}",
|
||||
"items": [{
|
||||
"quantity": 25
|
||||
}]
|
||||
cart_id: "cart_123",
|
||||
items: [{
|
||||
variant_id: "variant_123",
|
||||
quantity: 1,
|
||||
},
|
||||
{
|
||||
variant_id: "variant_456",
|
||||
quantity: 1,
|
||||
unit_price: 20
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -124,10 +155,17 @@ const myWorkflow = createWorkflow(
|
||||
const result = addToCartWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"cart_id": "{value}",
|
||||
"items": [{
|
||||
"quantity": 25
|
||||
}]
|
||||
cart_id: "cart_123",
|
||||
items: [{
|
||||
variant_id: "variant_123",
|
||||
quantity: 1,
|
||||
},
|
||||
{
|
||||
variant_id: "variant_456",
|
||||
quantity: 1,
|
||||
unit_price: 20
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -139,8 +177,40 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"addToCartWorkflow","steps":[{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":1},{"type":"when","condition":"{\n return !!variantIds.length\n }","depth":"2","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":2}]},{"type":"step","name":"validateVariantPricesStep","description":"This step validates the specified variant objects to ensure they have prices.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateVariantPricesStep/page.mdx","depth":3},{"type":"step","name":"getLineItemActionsStep","description":"This step returns lists of cart line items to create or update based on the\nprovided input.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.getLineItemActionsStep/page.mdx","depth":4},{"type":"workflow","name":"confirmVariantInventoryWorkflow","description":"This workflow confirms for one or more variants that their inventory has a required quantity.\n\n","link":"../core_flows.Cart.Workflows_Cart.confirmVariantInventoryWorkflow/page.mdx","depth":5},{"type":"step","name":"createLineItemsStep","description":"This step creates line item in a cart.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.createLineItemsStep/page.mdx","depth":6},{"type":"step","name":"updateLineItemsStep","description":"This step updates a cart's line items.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.updateLineItemsStep/page.mdx","depth":6},{"type":"step","name":"emitEventStep","description":"Emit an event.\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":7}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"addToCartWorkflow","steps":[{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":1},{"type":"step","name":"validateCartStep","description":"This step validates a cart to ensure it exists and is not completed.\nIf not valid, the step throws an error.\n\n:::tip\n\nYou can use the [retrieveCartStep](../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.retrieveCartStep/page.mdx) to retrieve a cart's details.\n\n:::","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateCartStep/page.mdx","depth":2},{"type":"hook","name":"validate","description":"This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.","link":"#validate","depth":3},{"type":"when","condition":"{\n return !!variantIds.length\n }","depth":"4","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":4}]},{"type":"step","name":"validateVariantPricesStep","description":"This step validates the specified variant objects to ensure they have prices.\nIf not valid, the step throws an error.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateVariantPricesStep/page.mdx","depth":5},{"type":"step","name":"validateLineItemPricesStep","description":"This step validates the specified line item objects to ensure they have prices.\nIf an item doesn't have a price, the step throws an error.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateLineItemPricesStep/page.mdx","depth":6},{"type":"step","name":"getLineItemActionsStep","description":"This step returns lists of cart line items to create or update based on the\nprovided input.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.getLineItemActionsStep/page.mdx","depth":7},{"type":"workflow","name":"confirmVariantInventoryWorkflow","description":"This workflow validates that product variants are in-stock at the specified sales channel, before adding them or updating their quantity in the cart. If a variant doesn't have sufficient quantity in-stock,\nthe workflow throws an error. If all variants have sufficient inventory, the workflow returns the cart's items with their inventory details.\n\nThis workflow is useful when confirming that a product variant has sufficient quantity to be added to or updated in the cart. It's executed\nby other cart-related workflows, such as [addToCartWorkflow](./page.mdx), to confirm that a product variant can be added to the cart at the specified quantity.\n\n:::note\n\nLearn more about the links between the product variant and sales channels and inventory items in [this documentation](https://docs.medusajs.com/resources/commerce-modules/product/links-to-other-modules).\n\n:::\n\nYou can use this workflow within your own customizations or custom workflows, allowing you to check whether a product variant has enough inventory quantity before adding them to the cart.","link":"../core_flows.Cart.Workflows_Cart.confirmVariantInventoryWorkflow/page.mdx","depth":8},{"type":"step","name":"createLineItemsStep","description":"This step creates line item in a cart.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.createLineItemsStep/page.mdx","depth":9},{"type":"step","name":"updateLineItemsStep","description":"This step updates a cart's line items.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.updateLineItemsStep/page.mdx","depth":9},{"type":"workflow","name":"refreshCartItemsWorkflow","description":"This workflow refreshes a cart to ensure its prices, promotion codes, taxes, and other details are applied correctly. It's useful\nafter making a chnge to a cart, such as after adding an item to the cart or adding a promotion code.\n\nThis workflow is used by other cart-related workflows, such as the [addToCartWorkflow](./page.mdx) after an item\nis added to the cart.\n\nYou can use this workflow within your own customizations or custom workflows, allowing you to refresh the cart after making updates to it in your\ncustom flows.","link":"../core_flows.Cart.Workflows_Cart.refreshCartItemsWorkflow/page.mdx","depth":10},{"type":"step","name":"emitEventStep"Line truncated
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"AddToCartWorkflowInputDTO","type":"[AddToCartWorkflowInputDTO](../../../../../types/interfaces/types.AddToCartWorkflowInputDTO/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[CreateCartCreateLineItemDTO](../../../../../types/interfaces/types.CreateCartCreateLineItemDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"quantity","type":"[BigNumberInput](../../../../../types/types/types.BigNumberInput/page.mdx)","description":"The quantity of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"variant_id","type":"`string`","description":"The ID of the variant to be added to the cart.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`string`","description":"The subtitle of the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`string`","description":"The thumbnail URL of the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`string`","description":"The ID of the product whose variant is being added to the cart.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_title","type":"`string`","description":"The title of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_description","type":"`string`","description":"The description of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_subtitle","type":"`string`","description":"The subtitle of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_type","type":"`string`","description":"The ID of the associated product's type.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_collection","type":"`string`","description":"The ID of the associated product's collection.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_handle","type":"`string`","description":"The handle of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_sku","type":"`string`","description":"The SKU of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_barcode","type":"`string`","description":"The barcode of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_title","type":"`string`","description":"The title of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_option_values","type":"`Record<string, unknown>`","description":"The associated variant's values for the product's options.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Whether the line item requires shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_discountable","type":"`boolean`","description":"Whether the line item is discountable.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_tax_inclusive","type":"`boolean`","description":"Whether the line item's price is tax inclusive. Learn more in \n[this documentation](https://docs.medusajs.com/resources/commerce-modules/pricing/tax-inclusive-pricing)","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"Whether the line item is a gift card.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"compare_at_unit_price","type":"[BigNumberInput](../../../../../types/types/types.BigNumberInput/page.mdx)","description":"The original price of the item before a promotion or sale.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `nLine truncated
|
||||
|
||||
## Output
|
||||
|
||||
<TypeList types={[{"name":"undefined","type":"`undefined`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"undefined","type":"`undefined`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="addToCartWorkflow"/>
|
||||
|
||||
## Hooks
|
||||
|
||||
Hooks allow you to inject custom functionalities into the workflow. You'll receive data from the workflow, as well as additional data sent through an HTTP request.
|
||||
|
||||
Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/workflow-hooks) and [Additional Data](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).
|
||||
|
||||
### validate
|
||||
|
||||
This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.
|
||||
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
import { addShippingMethodToCartWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
addShippingMethodToCartWorkflow.hooks.validate(
|
||||
(async ({ input, cart }, { container }) => {
|
||||
//TODO
|
||||
})
|
||||
)
|
||||
```
|
||||
|
||||
#### Input
|
||||
|
||||
Handlers consuming this hook accept the following input.
|
||||
|
||||
<TypeList types={[{"name":"input","type":"object","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[AddShippingMethodToCartWorkflowInput](../../../../interfaces/core_flows.AddShippingMethodToCartWorkflowInput/page.mdx)","description":"The data to add a shipping method to a cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The ID of the cart to add the shipping method to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`object`[]","description":"The shipping options to create the shipping methods from and add to the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"cart","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validate"/>
|
||||
+42
-9
@@ -21,9 +21,14 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `completeCartWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow completes a cart.
|
||||
This workflow completes a cart and places an order for the customer. It's executed by the
|
||||
[Complete Cart Store API Route](https://docs.medusajs.com/api/store#carts\_postcartsidcomplete).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/cart/workflows/complete-cart.ts#L48" />
|
||||
You can use this workflow within your own customizations or custom workflows, allowing you to wrap custom logic around completing a cart.
|
||||
For example, in the [Subscriptions recipe](https://docs.medusajs.com/resources/recipes/subscriptions/examples/standard#create-workflow),
|
||||
this workflow is used within another workflow that creates a subscription order.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/cart/workflows/complete-cart.ts#L81" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -44,7 +49,7 @@ export async function POST(
|
||||
const { result } = await completeCartWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"id": "id_aqIwIQaawJI96nsq"
|
||||
id: "cart_123"
|
||||
}
|
||||
})
|
||||
|
||||
@@ -69,7 +74,7 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await completeCartWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"id": "id_aqIwIQaawJI96nsq"
|
||||
id: "cart_123"
|
||||
}
|
||||
})
|
||||
|
||||
@@ -94,7 +99,7 @@ export default async function myCustomJob(
|
||||
const { result } = await completeCartWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"id": "id_aqIwIQaawJI96nsq"
|
||||
id: "cart_123"
|
||||
}
|
||||
})
|
||||
|
||||
@@ -120,7 +125,7 @@ const myWorkflow = createWorkflow(
|
||||
const result = completeCartWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"id": "id_aqIwIQaawJI96nsq"
|
||||
id: "cart_123"
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -132,12 +137,40 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"completeCartWorkflow","steps":[{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":1},{"type":"when","condition":"{\n return !orderId\n }","depth":"2","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":2},{"type":"step","name":"validateCartPaymentsStep","description":"This step validates a cart's payment sessions. Their status must\nbe `pending` or `requires_more`.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateCartPaymentsStep/page.mdx","depth":2},{"type":"step","name":"authorizePaymentSessionStep","description":"This step authorizes a payment session.\n\n","link":"../../../../Payment/Steps_Payment/functions/core_flows.Payment.Steps_Payment.authorizePaymentSessionStep/page.mdx","depth":2},{"type":"step","name":"createOrdersStep","description":"This step creates one or more orders.\n\n","link":"../../../../Order/Steps_Order/functions/core_flows.Order.Steps_Order.createOrdersStep/page.mdx","depth":2},{"type":"step","name":"createRemoteLinkStep","description":"This step creates remote links between two records of linked data models.\n\nLearn more in the [Remote Link documentation.](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#create-link).\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.createRemoteLinkStep/page.mdx","depth":2},{"type":"step","name":"updateCartsStep","description":"This step updates a cart.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.updateCartsStep/page.mdx","depth":2},{"type":"step","name":"reserveInventoryStep","description":"This step reserves the quantity of line items from the associated\nvariant's inventory.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.reserveInventoryStep/page.mdx","depth":2},{"type":"step","name":"emitEventStep","description":"Emit an event.\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":2}]}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"completeCartWorkflow","steps":[{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":1},{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":2},{"type":"hook","name":"validate","description":"This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.","link":"#validate","depth":3},{"type":"when","condition":"{\n return !orderId\n }","depth":"4","steps":[{"type":"step","name":"validateCartPaymentsStep","description":"This step validates a cart's payment sessions. Their status must\nbe `pending` or `requires_more`. If not valid, the step throws an error.\n\n:::tip\n\nYou can use the [retrieveCartStep](../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.retrieveCartStep/page.mdx) to retrieve a cart's details.\n\n:::","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateCartPaymentsStep/page.mdx","depth":4},{"type":"step","name":"authorizePaymentSessionStep","description":"This step authorizes a payment session.","link":"../../../../Payment/Steps_Payment/functions/core_flows.Payment.Steps_Payment.authorizePaymentSessionStep/page.mdx","depth":4},{"type":"step","name":"createOrdersStep","description":"This step creates one or more orders.","link":"../../../../Order/Steps_Order/functions/core_flows.Order.Steps_Order.createOrdersStep/page.mdx","depth":4},{"type":"step","name":"createRemoteLinkStep","description":"This step creates remote links between two records of linked data models.\n\nLearn more in the [Remote Link documentation.](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#create-link).","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.createRemoteLinkStep/page.mdx","depth":4},{"type":"step","name":"updateCartsStep","description":"This step updates a cart.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.updateCartsStep/page.mdx","depth":4},{"type":"step","name":"reserveInventoryStep","description":"This step reserves the quantity of line items from the associated\nvariant's inventory.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.reserveInventoryStep/page.mdx","depth":4},{"type":"step","name":"emitEventStep","description":"Emit an event.","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":4}]}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"CompleteCartWorkflowInput","type":"[CompleteCartWorkflowInput](../../../../types/core_flows.CompleteCartWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="completeCartWorkflow"/>
|
||||
<TypeList types={[{"name":"CompleteCartWorkflowInput","type":"[CompleteCartWorkflowInput](../../../../types/core_flows.CompleteCartWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"The data to complete a cart and place an order.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart to complete.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="completeCartWorkflow"/>
|
||||
|
||||
## Output
|
||||
|
||||
<TypeList types={[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="completeCartWorkflow"/>
|
||||
<TypeList types={[{"name":"CompleteCartWorkflowOutput","type":"[CompleteCartWorkflowOutput](../../../../types/core_flows.CompleteCartWorkflowOutput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order that was created.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="completeCartWorkflow"/>
|
||||
|
||||
## Hooks
|
||||
|
||||
Hooks allow you to inject custom functionalities into the workflow. You'll receive data from the workflow, as well as additional data sent through an HTTP request.
|
||||
|
||||
Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/workflow-hooks) and [Additional Data](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).
|
||||
|
||||
### validate
|
||||
|
||||
This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.
|
||||
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
import { addShippingMethodToCartWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
addShippingMethodToCartWorkflow.hooks.validate(
|
||||
(async ({ input, cart }, { container }) => {
|
||||
//TODO
|
||||
})
|
||||
)
|
||||
```
|
||||
|
||||
#### Input
|
||||
|
||||
Handlers consuming this hook accept the following input.
|
||||
|
||||
<TypeList types={[{"name":"input","type":"object","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[AddShippingMethodToCartWorkflowInput](../../../../interfaces/core_flows.AddShippingMethodToCartWorkflowInput/page.mdx)","description":"The data to add a shipping method to a cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The ID of the cart to add the shipping method to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`object`[]","description":"The shipping options to create the shipping methods from and add to the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"cart","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validate"/>
|
||||
+222
-63
@@ -12,12 +12,54 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `confirmVariantInventoryWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow confirms for one or more variants that their inventory has a required quantity.
|
||||
This workflow validates that product variants are in-stock at the specified sales channel, before adding them or updating their quantity in the cart. If a variant doesn't have sufficient quantity in-stock,
|
||||
the workflow throws an error. If all variants have sufficient inventory, the workflow returns the cart's items with their inventory details.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/cart/workflows/confirm-variant-inventory.ts#L27" />
|
||||
This workflow is useful when confirming that a product variant has sufficient quantity to be added to or updated in the cart. It's executed
|
||||
by other cart-related workflows, such as [addToCartWorkflow](../core_flows.Cart.Workflows_Cart.addToCartWorkflow/page.mdx), to confirm that a product variant can be added to the cart at the specified quantity.
|
||||
|
||||
:::note
|
||||
|
||||
Learn more about the links between the product variant and sales channels and inventory items in [this documentation](https://docs.medusajs.com/resources/commerce-modules/product/links-to-other-modules).
|
||||
|
||||
:::
|
||||
|
||||
You can use this workflow within your own customizations or custom workflows, allowing you to check whether a product variant has enough inventory quantity before adding them to the cart.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/cart/workflows/confirm-variant-inventory.ts#L143" />
|
||||
|
||||
## Examples
|
||||
|
||||
You can retrieve a variant's required details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query):
|
||||
|
||||
```ts workflow={false}
|
||||
const { data: variants } = await query.graph({
|
||||
entity: "variant",
|
||||
fields: [
|
||||
"id",
|
||||
"manage_inventory",
|
||||
"inventory_items.inventory_item_id",
|
||||
"inventory_items.required_quantity",
|
||||
"inventory_items.inventory.requires_shipping",
|
||||
"inventory_items.inventory.location_levels.stock_locations.id",
|
||||
"inventory_items.inventory.location_levels.stock_locations.name",
|
||||
"inventory_items.inventory.location_levels.stock_locations.sales_channels.id",
|
||||
"inventory_items.inventory.location_levels.stock_locations.sales_channels.name",
|
||||
],
|
||||
filters: {
|
||||
id: ["variant_123"]
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
:::note
|
||||
|
||||
In a workflow, use [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep) instead.
|
||||
|
||||
:::
|
||||
|
||||
Then, pass the variant's data with the other required data to the workflow:
|
||||
|
||||
<CodeTabs group="workflow-exection">
|
||||
<CodeTab label="API Route" value="api-route">
|
||||
|
||||
@@ -35,21 +77,12 @@ export async function POST(
|
||||
const { result } = await confirmVariantInventoryWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"sales_channel_id": "{value}",
|
||||
"variants": [{
|
||||
"id": "id_KTOvaT83mYSDyTJ7qdw",
|
||||
"manage_inventory": true,
|
||||
"inventory_items": [{
|
||||
"inventory_item_id": "{value}",
|
||||
"variant_id": "{value}",
|
||||
"required_quantity": 16,
|
||||
"inventory": [{
|
||||
"location_levels": {}
|
||||
}]
|
||||
}]
|
||||
}],
|
||||
"items": [{
|
||||
"quantity": 47
|
||||
sales_channel_id: "sc_123",
|
||||
// @ts-ignore
|
||||
variants,
|
||||
items: [{
|
||||
variant_id: "variant_123",
|
||||
quantity: 1
|
||||
}]
|
||||
}
|
||||
})
|
||||
@@ -75,21 +108,12 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await confirmVariantInventoryWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"sales_channel_id": "{value}",
|
||||
"variants": [{
|
||||
"id": "id_KTOvaT83mYSDyTJ7qdw",
|
||||
"manage_inventory": true,
|
||||
"inventory_items": [{
|
||||
"inventory_item_id": "{value}",
|
||||
"variant_id": "{value}",
|
||||
"required_quantity": 16,
|
||||
"inventory": [{
|
||||
"location_levels": {}
|
||||
}]
|
||||
}]
|
||||
}],
|
||||
"items": [{
|
||||
"quantity": 47
|
||||
sales_channel_id: "sc_123",
|
||||
// @ts-ignore
|
||||
variants,
|
||||
items: [{
|
||||
variant_id: "variant_123",
|
||||
quantity: 1
|
||||
}]
|
||||
}
|
||||
})
|
||||
@@ -115,21 +139,12 @@ export default async function myCustomJob(
|
||||
const { result } = await confirmVariantInventoryWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"sales_channel_id": "{value}",
|
||||
"variants": [{
|
||||
"id": "id_KTOvaT83mYSDyTJ7qdw",
|
||||
"manage_inventory": true,
|
||||
"inventory_items": [{
|
||||
"inventory_item_id": "{value}",
|
||||
"variant_id": "{value}",
|
||||
"required_quantity": 16,
|
||||
"inventory": [{
|
||||
"location_levels": {}
|
||||
}]
|
||||
}]
|
||||
}],
|
||||
"items": [{
|
||||
"quantity": 47
|
||||
sales_channel_id: "sc_123",
|
||||
// @ts-ignore
|
||||
variants,
|
||||
items: [{
|
||||
variant_id: "variant_123",
|
||||
quantity: 1
|
||||
}]
|
||||
}
|
||||
})
|
||||
@@ -156,21 +171,165 @@ const myWorkflow = createWorkflow(
|
||||
const result = confirmVariantInventoryWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"sales_channel_id": "{value}",
|
||||
"variants": [{
|
||||
"id": "id_KTOvaT83mYSDyTJ7qdw",
|
||||
"manage_inventory": true,
|
||||
"inventory_items": [{
|
||||
"inventory_item_id": "{value}",
|
||||
"variant_id": "{value}",
|
||||
"required_quantity": 16,
|
||||
"inventory": [{
|
||||
"location_levels": {}
|
||||
}]
|
||||
}]
|
||||
sales_channel_id: "sc_123",
|
||||
// @ts-ignore
|
||||
variants,
|
||||
items: [{
|
||||
variant_id: "variant_123",
|
||||
quantity: 1
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
</CodeTabs>
|
||||
|
||||
When updating an item quantity:
|
||||
|
||||
<CodeTabs group="workflow-exection">
|
||||
<CodeTab label="API Route" value="api-route">
|
||||
|
||||
```ts title="src/api/workflow/route.ts"
|
||||
import type {
|
||||
MedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { confirmVariantInventoryWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
export async function POST(
|
||||
req: MedusaRequest,
|
||||
res: MedusaResponse
|
||||
) {
|
||||
const { result } = await confirmVariantInventoryWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
sales_channel_id: "sc_123",
|
||||
// @ts-ignore
|
||||
variants,
|
||||
items: [{
|
||||
variant_id: "variant_123",
|
||||
quantity: 1
|
||||
}],
|
||||
itemsToUpdate: [{
|
||||
data: {
|
||||
variant_id: "variant_123",
|
||||
quantity: 2
|
||||
}
|
||||
}]
|
||||
}
|
||||
})
|
||||
|
||||
res.send(result)
|
||||
}
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
<CodeTab label="Subscriber" value="subscriber">
|
||||
|
||||
```ts title="src/subscribers/order-placed.ts"
|
||||
import {
|
||||
type SubscriberConfig,
|
||||
type SubscriberArgs,
|
||||
} from "@medusajs/framework"
|
||||
import { confirmVariantInventoryWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
export default async function handleOrderPlaced({
|
||||
event: { data },
|
||||
container,
|
||||
}: SubscriberArgs < { id: string } > ) {
|
||||
const { result } = await confirmVariantInventoryWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
sales_channel_id: "sc_123",
|
||||
// @ts-ignore
|
||||
variants,
|
||||
items: [{
|
||||
variant_id: "variant_123",
|
||||
quantity: 1
|
||||
}],
|
||||
itemsToUpdate: [{
|
||||
data: {
|
||||
variant_id: "variant_123",
|
||||
quantity: 2
|
||||
}
|
||||
}]
|
||||
}
|
||||
})
|
||||
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
export const config: SubscriberConfig = {
|
||||
event: "order.placed",
|
||||
}
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
<CodeTab label="Scheduled Job" value="scheduled-job">
|
||||
|
||||
```ts title="src/jobs/message-daily.ts"
|
||||
import { MedusaContainer } from "@medusajs/framework/types"
|
||||
import { confirmVariantInventoryWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
export default async function myCustomJob(
|
||||
container: MedusaContainer
|
||||
) {
|
||||
const { result } = await confirmVariantInventoryWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
sales_channel_id: "sc_123",
|
||||
// @ts-ignore
|
||||
variants,
|
||||
items: [{
|
||||
variant_id: "variant_123",
|
||||
quantity: 1
|
||||
}],
|
||||
itemsToUpdate: [{
|
||||
data: {
|
||||
variant_id: "variant_123",
|
||||
quantity: 2
|
||||
}
|
||||
}]
|
||||
}
|
||||
})
|
||||
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
export const config = {
|
||||
name: "run-once-a-day",
|
||||
schedule: "0 0 * * *",
|
||||
}
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
<CodeTab label="Another Workflow" value="another-workflow">
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { confirmVariantInventoryWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const result = confirmVariantInventoryWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
sales_channel_id: "sc_123",
|
||||
// @ts-ignore
|
||||
variants,
|
||||
items: [{
|
||||
variant_id: "variant_123",
|
||||
quantity: 1
|
||||
}],
|
||||
"items": [{
|
||||
"quantity": 47
|
||||
itemsToUpdate: [{
|
||||
data: {
|
||||
variant_id: "variant_123",
|
||||
quantity: 2
|
||||
}
|
||||
}]
|
||||
}
|
||||
})
|
||||
@@ -183,7 +342,7 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"confirmVariantInventoryWorkflow","steps":[{"type":"step","name":"confirmInventoryStep","description":"This step confirms for one or more variants that their inventory has a required quantity.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.confirmInventoryStep/page.mdx","depth":1}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"confirmVariantInventoryWorkflow","steps":[{"type":"step","name":"confirmInventoryStep","description":"This step validates that items in the cart have sufficient inventory quantity.\nIf an item doesn't have sufficient inventory, an error is thrown.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.confirmInventoryStep/page.mdx","depth":1}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
@@ -191,4 +350,4 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Output
|
||||
|
||||
<TypeList types={[{"name":"ConfirmVariantInventoryWorkflowOutput","type":"[ConfirmVariantInventoryWorkflowOutput](../../../../interfaces/core_flows.ConfirmVariantInventoryWorkflowOutput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"items","type":"`object`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"inventory_item_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"required_quantity","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"allow_backorder","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"[BigNumberInput](../../../../../types/types/types.BigNumberInput/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"location_ids","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="confirmVariantInventoryWorkflow"/>
|
||||
<TypeList types={[{"name":"ConfirmVariantInventoryWorkflowOutput","type":"[ConfirmVariantInventoryWorkflowOutput](../../../../interfaces/core_flows.ConfirmVariantInventoryWorkflowOutput/page.mdx)","optional":false,"defaultValue":"","description":"The details of the cart items with inventory result computed for the specified input.","expandable":false,"children":[{"name":"items","type":"`object`[]","description":"The cart's line items with the computed inventory result.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"inventory_item_id","type":"`string`","description":"The ID of the inventory item used to retrieve the item's available quantity.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"required_quantity","type":"`number`","description":"The number of units a single quantity is equivalent to. For example, if a customer orders one quantity of the variant, Medusa checks the availability of the quantity multiplied by the\nvalue set for `required_quantity`. When the customer orders the quantity, Medusa reserves the ordered quantity multiplied by the value set for `required_quantity`.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"allow_backorder","type":"`boolean`","description":"Whether the variant can be ordered even if it's out of stock. If a variant has this enabled, the workflow doesn't throw an error.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"[BigNumberInput](../../../../../types/types/types.BigNumberInput/page.mdx)","description":"The quantity in the cart. If you provided `itemsToUpdate` in the input, this will be the updated quantity.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"location_ids","type":"`string`[]","description":"The ID of the stock locations that the computed inventory quantity is available in.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"The line item's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="confirmVariantInventoryWorkflow"/>
|
||||
+26
-4
@@ -24,14 +24,14 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `createCartWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow creates and returns a cart. You can set the cart's items, region, customer, and other details. This workflow is executed by the
|
||||
This workflow creates and returns a cart. You can set the cart's items, region, customer, and other details. This workflow is executed by the
|
||||
[Create Cart Store API Route](https://docs.medusajs.com/api/store#carts\_postcarts).
|
||||
|
||||
This workflow has a hook that allows you to perform custom actions on the created cart. You can see an example in [this guide](https://docs.medusajs.com/resources/commerce-modules/cart/extend#step-4-consume-cartcreated-workflow-hook).
|
||||
|
||||
You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around cart creation.
|
||||
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around cart creation.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/cart/workflows/create-carts.ts#L77" />
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/cart/workflows/create-carts.ts#L79" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -172,7 +172,7 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"createCartWorkflow","steps":[{"type":"step","name":"findSalesChannelStep","description":"This step either retrieves a sales channel either using the ID provided as an input, or, if no ID\nis provided, the default sales channel of the first store.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.findSalesChannelStep/page.mdx","depth":1},{"type":"step","name":"findOneOrAnyRegionStep","description":"This step retrieves a region either by the provided ID or the first region in the first store.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.findOneOrAnyRegionStep/page.mdx","depth":1},{"type":"step","name":"findOrCreateCustomerStep","description":"This step either finds a customer matching the specified ID, or finds / create a customer\nmatching the specified email. If both ID and email are provided, ID takes precedence.\nIf the customer is a guest, the email is updated to the provided email.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.findOrCreateCustomerStep/page.mdx","depth":1},{"type":"when","condition":"{\n return !!variantIds.length\n }","depth":"2","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":2}]},{"type":"step","name":"validateVariantPricesStep","description":"This step validates the specified variant objects to ensure they have prices.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateVariantPricesStep/page.mdx","depth":3},{"type":"workflow","name":"confirmVariantInventoryWorkflow","description":"This workflow confirms for one or more variants that their inventory has a required quantity.\n\n","link":"../core_flows.Cart.Workflows_Cart.confirmVariantInventoryWorkflow/page.mdx","depth":4},{"type":"step","name":"createCartsStep","description":"This step creates a cart.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.createCartsStep/page.mdx","depth":5},{"type":"workflow","name":"updateTaxLinesWorkflow","description":"This workflow updates a cart's tax lines.\n\n","link":"../core_flows.Cart.Workflows_Cart.updateTaxLinesWorkflow/page.mdx","depth":6},{"type":"workflow","name":"updateCartPromotionsWorkflow","description":"This workflow updates a cart's promotions.\n\n","link":"../core_flows.Cart.Workflows_Cart.updateCartPromotionsWorkflow/page.mdx","depth":7},{"type":"workflow","name":"refreshPaymentCollectionForCartWorkflow","description":"This workflow refreshes the payment collections of a cart.\n\n","link":"../core_flows.Cart.Workflows_Cart.refreshPaymentCollectionForCartWorkflow/page.mdx","depth":8},{"type":"step","name":"emitEventStep","description":"Emit an event.\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":8},{"type":"hook","name":"cartCreated","description":"This hook is executed after a cart is created. You can consume this hook to perform custom actions on the created cart.\n\n","link":"#cartCreated","depth":9}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"createCartWorkflow","steps":[{"type":"step","name":"findSalesChannelStep","description":"This step either retrieves a sales channel either using the ID provided as an input, or, if no ID\nis provided, the default sales channel of the first store.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.findSalesChannelStep/page.mdx","depth":1},{"type":"step","name":"findOneOrAnyRegionStep","description":"This step retrieves a region either by the provided ID or the first region in the first store.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.findOneOrAnyRegionStep/page.mdx","depth":1},{"type":"step","name":"findOrCreateCustomerStep","description":"This step either finds a customer matching the specified ID, or finds / create a customer\nmatching the specified email. If both ID and email are provided, ID takes precedence.\nIf the customer is a guest, the email is updated to the provided email.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.findOrCreateCustomerStep/page.mdx","depth":1},{"type":"when","condition":"{\n return !!variantIds.length\n }","depth":"2","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":2}]},{"type":"step","name":"validateVariantPricesStep","description":"This step validates the specified variant objects to ensure they have prices.\nIf not valid, the step throws an error.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateVariantPricesStep/page.mdx","depth":3},{"type":"workflow","name":"confirmVariantInventoryWorkflow","description":"This workflow validates that product variants are in-stock at the specified sales channel, before adding them or updating their quantity in the cart. If a variant doesn't have sufficient quantity in-stock,\nthe workflow throws an error. If all variants have sufficient inventory, the workflow returns the cart's items with their inventory details.\n\nThis workflow is useful when confirming that a product variant has sufficient quantity to be added to or updated in the cart. It's executed\nby other cart-related workflows, such as [addToCartWorkflow](../core_flows.Cart.Workflows_Cart.addToCartWorkflow/page.mdx), to confirm that a product variant can be added to the cart at the specified quantity.\n\n:::note\n\nLearn more about the links between the product variant and sales channels and inventory items in [this documentation](https://docs.medusajs.com/resources/commerce-modules/product/links-to-other-modules).\n\n:::\n\nYou can use this workflow within your own customizations or custom workflows, allowing you to check whether a product variant has enough inventory quantity before adding them to the cart.","link":"../core_flows.Cart.Workflows_Cart.confirmVariantInventoryWorkflow/page.mdx","depth":4},{"type":"step","name":"validateLineItemPricesStep","description":"This step validates the specified line item objects to ensure they have prices.\nIf an item doesn't have a price, the step throws an error.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateLineItemPricesStep/page.mdx","depth":5},{"type":"hook","name":"validate","description":"This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.","link":"#validate","depth":6},{"type":"step","name":"createCartsStep","description":"This step creates a cart.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.createCartsStep/page.mdx","depth":7},{"type":"workflow","name":"updateTaxLinesWorkflow","description":"This workflow updates a cart's tax lines that are applied on line items and shipping methods. You can update the line item's quantity, unit price, and more. This workflow is executed\nby the [Calculate Taxes Store API Route](https://docs.medusajs.com/api/store#carts\\_postcartsidtaxes).\n\nYou can use this workflow within your own customizations or custom workflows, allowing you to update a cart's tax lines in your custom flows.","link":"../core_flows.Cart.Workflows_Cart.updateTaxLinesWorkflow/page.mdx","depth":8},{"type":"workflow","name":"updateCartPromotionsWorkflow","description":"This workflow updates a cart's promotions, applying or removing promotion codes from the cart. It also computes the adjustments\nthat need to be applied to the cart's line items and shipping methods based on the promotions applied. This workflow is used by\n[Add Promotions Line truncated
|
||||
|
||||
## Input
|
||||
|
||||
@@ -188,6 +188,28 @@ Hooks allow you to inject custom functionalities into the workflow. You'll recei
|
||||
|
||||
Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/workflow-hooks) and [Additional Data](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).
|
||||
|
||||
### validate
|
||||
|
||||
This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.
|
||||
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
import { addShippingMethodToCartWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
addShippingMethodToCartWorkflow.hooks.validate(
|
||||
(async ({ input, cart }, { container }) => {
|
||||
//TODO
|
||||
})
|
||||
)
|
||||
```
|
||||
|
||||
#### Input
|
||||
|
||||
Handlers consuming this hook accept the following input.
|
||||
|
||||
<TypeList types={[{"name":"input","type":"object","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[AddShippingMethodToCartWorkflowInput](../../../../interfaces/core_flows.AddShippingMethodToCartWorkflowInput/page.mdx)","description":"The data to add a shipping method to a cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The ID of the cart to add the shipping method to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`object`[]","description":"The shipping options to create the shipping methods from and add to the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"cart","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validate"/>
|
||||
|
||||
### cartCreated
|
||||
|
||||
This hook is executed after a cart is created. You can consume this hook to perform custom actions on the created cart.
|
||||
|
||||
+22
-7
@@ -14,9 +14,12 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `createPaymentCollectionForCartWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow creates a payment collection for a cart.
|
||||
This workflow creates a payment collection for a cart. It's executed by the
|
||||
[Create Payment Collection Store API Route](https://docs.medusajs.com/api/store#payment-collections\_postpaymentcollections).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/cart/workflows/create-payment-collection-for-cart.ts#L35" />
|
||||
You can use this workflow within your own customizations or custom workflows, allowing you to wrap custom logic around adding creating a payment collection for a cart.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/cart/workflows/create-payment-collection-for-cart.ts#L81" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -37,7 +40,10 @@ export async function POST(
|
||||
const { result } = await createPaymentCollectionForCartWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
metadata: {
|
||||
sandbox: true
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -62,7 +68,10 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await createPaymentCollectionForCartWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
metadata: {
|
||||
sandbox: true
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -87,7 +96,10 @@ export default async function myCustomJob(
|
||||
const { result } = await createPaymentCollectionForCartWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
metadata: {
|
||||
sandbox: true
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -113,7 +125,10 @@ const myWorkflow = createWorkflow(
|
||||
const result = createPaymentCollectionForCartWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
metadata: {
|
||||
sandbox: true
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -125,7 +140,7 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"createPaymentCollectionForCartWorkflow","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":1},{"type":"step","name":"validateExistingPaymentCollectionStep","description":"This step validates that a cart doesn't have a payment collection.\n\n","link":"../core_flows.Cart.Workflows_Cart.validateExistingPaymentCollectionStep/page.mdx","depth":2},{"type":"step","name":"createPaymentCollectionsStep","description":"This step creates payment collections in a cart.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.createPaymentCollectionsStep/page.mdx","depth":3},{"type":"step","name":"createRemoteLinkStep","description":"This step creates remote links between two records of linked data models.\n\nLearn more in the [Remote Link documentation.](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#create-link).\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.createRemoteLinkStep/page.mdx","depth":4}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"createPaymentCollectionForCartWorkflow","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":1},{"type":"step","name":"validateCartStep","description":"This step validates a cart to ensure it exists and is not completed.\nIf not valid, the step throws an error.\n\n:::tip\n\nYou can use the [retrieveCartStep](../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.retrieveCartStep/page.mdx) to retrieve a cart's details.\n\n:::","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateCartStep/page.mdx","depth":2},{"type":"step","name":"validateExistingPaymentCollectionStep","description":"This step validates that a cart doesn't have a payment collection.\nIf the cart has a payment collection, the step throws an error.\n\n:::tip\n\nYou can use the retrieveCartStep to retrieve a cart's details.\n\n:::","link":"../core_flows.Cart.Workflows_Cart.validateExistingPaymentCollectionStep/page.mdx","depth":2},{"type":"step","name":"createPaymentCollectionsStep","description":"This step creates payment collections in a cart.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.createPaymentCollectionsStep/page.mdx","depth":3},{"type":"step","name":"createRemoteLinkStep","description":"This step creates remote links between two records of linked data models.\n\nLearn more in the [Remote Link documentation.](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#create-link).","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.createRemoteLinkStep/page.mdx","depth":4}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
|
||||
+39
-8
@@ -14,9 +14,16 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `listShippingOptionsForCartWithPricingWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow lists the shipping options of a cart.
|
||||
This workflow lists shipping options that can be used during checkout for a cart. It also retrieves the prices
|
||||
of these shipping options, including calculated prices that may be retrieved from third-party providers.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/cart/workflows/list-shipping-options-for-cart-with-pricing.ts#L44" />
|
||||
This workflow is executed in other cart-related workflows, such as [addShippingMethodToCartWorkflow](../core_flows.Cart.Workflows_Cart.addShippingMethodToCartWorkflow/page.mdx) to retrieve the
|
||||
price of the shipping method being added to the cart.
|
||||
|
||||
You can use this workflow within your own customizations or custom workflows, allowing you to retrieve the shipping options of a cart and their prices
|
||||
in your custom flows.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/cart/workflows/list-shipping-options-for-cart-with-pricing.ts#L74" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -38,7 +45,13 @@ export async function POST(
|
||||
.scope)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
options: [{
|
||||
id: "so_123",
|
||||
data: {
|
||||
carrier_code: "fedex"
|
||||
}
|
||||
}]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -64,7 +77,13 @@ export default async function handleOrderPlaced({
|
||||
container)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
options: [{
|
||||
id: "so_123",
|
||||
data: {
|
||||
carrier_code: "fedex"
|
||||
}
|
||||
}]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -90,7 +109,13 @@ export default async function myCustomJob(
|
||||
container)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
options: [{
|
||||
id: "so_123",
|
||||
data: {
|
||||
carrier_code: "fedex"
|
||||
}
|
||||
}]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -116,7 +141,13 @@ const myWorkflow = createWorkflow(
|
||||
const result = listShippingOptionsForCartWithPricingWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
options: [{
|
||||
id: "so_123",
|
||||
data: {
|
||||
carrier_code: "fedex"
|
||||
}
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -128,11 +159,11 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"listShippingOptionsForCartWithPricingWorkflow","steps":[{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":1},{"type":"step","name":"validatePresenceOfStep","description":"This step validates the presence of attributes on an object\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.validatePresenceOfStep/page.mdx","depth":2},{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":3},{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":4},{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":5},{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":5},{"type":"step","name":"calculateShippingOptionsPricesStep","description":"This step calculates the prices for one or more shipping options.\n\n","link":"../../../../Fulfillment/Steps_Fulfillment/functions/core_flows.Fulfillment.Steps_Fulfillment.calculateShippingOptionsPricesStep/page.mdx","depth":6}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"listShippingOptionsForCartWithPricingWorkflow","steps":[{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":1},{"type":"step","name":"validatePresenceOfStep","description":"This step validates the presence of attributes on an object","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.validatePresenceOfStep/page.mdx","depth":2},{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":3},{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":4},{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":5},{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":5},{"type":"step","name":"calculateShippingOptionsPricesStep","description":"This step calculates the prices for one or more shipping options.","link":"../../../../Fulfillment/Steps_Fulfillment/functions/core_flows.Fulfillment.Steps_Fulfillment.calculateShippingOptionsPricesStep/page.mdx","depth":6}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"cart_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`object`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"is_return","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"enabled_in_store","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="listShippingOptionsForCartWithPricingWorkflow"/>
|
||||
<TypeList types={[{"name":"ListShippingOptionsForCartWithPricingWorkflowInput","type":"`ListShippingOptionsForCartWithPricingWorkflowInput`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="listShippingOptionsForCartWithPricingWorkflow"/>
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+23
-8
@@ -13,9 +13,20 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `listShippingOptionsForCartWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow lists the shipping options of a cart.
|
||||
This workflow lists the shipping options of a cart. It's executed by the
|
||||
[List Shipping Options Store API Route](https://docs.medusajs.com/api/store#shipping-options\_getshippingoptions).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/cart/workflows/list-shipping-options-for-cart.ts#L16" />
|
||||
:::note
|
||||
|
||||
This workflow doesn't retrieve the calculated prices of the shipping options. If you need to retrieve the prices of the shipping options,
|
||||
use the [listShippingOptionsForCartWithPricingWorkflow](../core_flows.Cart.Workflows_Cart.listShippingOptionsForCartWithPricingWorkflow/page.mdx) workflow.
|
||||
|
||||
:::
|
||||
|
||||
You can use this workflow within your own customizations or custom workflows, allowing you to wrap custom logic around to retrieve the shipping options of a cart
|
||||
in your custom flows.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/cart/workflows/list-shipping-options-for-cart.ts#L41" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -36,7 +47,8 @@ export async function POST(
|
||||
const { result } = await listShippingOptionsForCartWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
option_ids: ["so_123"]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -61,7 +73,8 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await listShippingOptionsForCartWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
option_ids: ["so_123"]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -86,7 +99,8 @@ export default async function myCustomJob(
|
||||
const { result } = await listShippingOptionsForCartWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
option_ids: ["so_123"]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -112,7 +126,8 @@ const myWorkflow = createWorkflow(
|
||||
const result = listShippingOptionsForCartWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
option_ids: ["so_123"]
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -124,8 +139,8 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"listShippingOptionsForCartWorkflow","steps":[{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":1},{"type":"step","name":"validatePresenceOfStep","description":"This step validates the presence of attributes on an object\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.validatePresenceOfStep/page.mdx","depth":2},{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":3},{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":4}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"listShippingOptionsForCartWorkflow","steps":[{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":1},{"type":"step","name":"validatePresenceOfStep","description":"This step validates the presence of attributes on an object","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.validatePresenceOfStep/page.mdx","depth":2},{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":3},{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":4}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"cart_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"option_ids","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_return","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"enabled_in_store","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="listShippingOptionsForCartWorkflow"/>
|
||||
<TypeList types={[{"name":"ListShippingOptionsForCartWorkflowInput","type":"`ListShippingOptionsForCartWorkflowInput`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="listShippingOptionsForCartWorkflow"/>
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
---
|
||||
slug: /references/medusa-workflows/refreshCartItemsWorkflow
|
||||
sidebar_label: refreshCartItemsWorkflow
|
||||
tags:
|
||||
- remote query
|
||||
- cart
|
||||
- workflow
|
||||
- query
|
||||
- fulfillment
|
||||
- tax
|
||||
- promotion
|
||||
- link
|
||||
- payment
|
||||
- logger
|
||||
---
|
||||
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
# refreshCartItemsWorkflow - Medusa Core Workflows Reference
|
||||
|
||||
This documentation provides a reference to the `refreshCartItemsWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow refreshes a cart to ensure its prices, promotion codes, taxes, and other details are applied correctly. It's useful
|
||||
after making a chnge to a cart, such as after adding an item to the cart or adding a promotion code.
|
||||
|
||||
This workflow is used by other cart-related workflows, such as the [addToCartWorkflow](../core_flows.Cart.Workflows_Cart.addToCartWorkflow/page.mdx) after an item
|
||||
is added to the cart.
|
||||
|
||||
You can use this workflow within your own customizations or custom workflows, allowing you to refresh the cart after making updates to it in your
|
||||
custom flows.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/cart/workflows/refresh-cart-items.ts#L71" />
|
||||
|
||||
## Examples
|
||||
|
||||
<CodeTabs group="workflow-exection">
|
||||
<CodeTab label="API Route" value="api-route">
|
||||
|
||||
```ts title="src/api/workflow/route.ts"
|
||||
import type {
|
||||
MedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { refreshCartItemsWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
export async function POST(
|
||||
req: MedusaRequest,
|
||||
res: MedusaResponse
|
||||
) {
|
||||
const { result } = await refreshCartItemsWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
cart_id: "cart_123",
|
||||
}
|
||||
})
|
||||
|
||||
res.send(result)
|
||||
}
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
<CodeTab label="Subscriber" value="subscriber">
|
||||
|
||||
```ts title="src/subscribers/order-placed.ts"
|
||||
import {
|
||||
type SubscriberConfig,
|
||||
type SubscriberArgs,
|
||||
} from "@medusajs/framework"
|
||||
import { refreshCartItemsWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
export default async function handleOrderPlaced({
|
||||
event: { data },
|
||||
container,
|
||||
}: SubscriberArgs < { id: string } > ) {
|
||||
const { result } = await refreshCartItemsWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
cart_id: "cart_123",
|
||||
}
|
||||
})
|
||||
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
export const config: SubscriberConfig = {
|
||||
event: "order.placed",
|
||||
}
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
<CodeTab label="Scheduled Job" value="scheduled-job">
|
||||
|
||||
```ts title="src/jobs/message-daily.ts"
|
||||
import { MedusaContainer } from "@medusajs/framework/types"
|
||||
import { refreshCartItemsWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
export default async function myCustomJob(
|
||||
container: MedusaContainer
|
||||
) {
|
||||
const { result } = await refreshCartItemsWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
cart_id: "cart_123",
|
||||
}
|
||||
})
|
||||
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
export const config = {
|
||||
name: "run-once-a-day",
|
||||
schedule: "0 0 * * *",
|
||||
}
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
<CodeTab label="Another Workflow" value="another-workflow">
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { refreshCartItemsWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const result = refreshCartItemsWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
cart_id: "cart_123",
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
</CodeTabs>
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"refreshCartItemsWorkflow","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":1},{"type":"when","condition":"{\n return !!variantIds.length\n }","depth":"2","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":2}]},{"type":"step","name":"validateVariantPricesStep","description":"This step validates the specified variant objects to ensure they have prices.\nIf not valid, the step throws an error.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateVariantPricesStep/page.mdx","depth":3},{"type":"hook","name":"validate","description":"This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.","link":"#validate","depth":4},{"type":"step","name":"updateLineItemsStep","description":"This step updates a cart's line items.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.updateLineItemsStep/page.mdx","depth":5},{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":6},{"type":"workflow","name":"refreshCartShippingMethodsWorkflow","description":"This workflow refreshes a cart's shipping methods, ensuring that their associated shipping options can still be used on the cart,\nand retrieve their correct pricing after a cart update. This workflow is used by the [refreshCartItemsWorkflow](./page.mdx).\n\nYou can use this workflow within your own customizations or custom workflows, allowing you to refresh the cart's shipping method after making updates to the cart.","link":"../core_flows.Cart.Workflows_Cart.refreshCartShippingMethodsWorkflow/page.mdx","depth":7},{"type":"workflow","name":"updateTaxLinesWorkflow","description":"This workflow updates a cart's tax lines that are applied on line items and shipping methods. You can update the line item's quantity, unit price, and more. This workflow is executed\nby the [Calculate Taxes Store API Route](https://docs.medusajs.com/api/store#carts\\_postcartsidtaxes).\n\nYou can use this workflow within your own customizations or custom workflows, allowing you to update a cart's tax lines in your custom flows.","link":"../core_flows.Cart.Workflows_Cart.updateTaxLinesWorkflow/page.mdx","depth":8},{"type":"workflow","name":"updateCartPromotionsWorkflow","description":"This workflow updates a cart's promotions, applying or removing promotion codes from the cart. It also computes the adjustments\nthat need to be applied to the cart's line items and shipping methods based on the promotions applied. This workflow is used by\n[Add Promotions Store API Route](https://docs.medusajs.com/api/store#carts\\_postcartsidpromotions).\n\nYou can use this workflow within your own customizations or custom workflows, allowing you to update a cart's promotions within your custom flows.","link":"../core_flows.Cart.Workflows_Cart.updateCartPromotionsWorkflow/page.mdx","depth":9},{"type":"workflow","name":"refreshPaymentCollectionForCartWorkflow","description":"This workflow refreshes a cart's payment collection, which is useful once the cart is created or when its details\nare updated. If the cart's total changes to the amount in its payment collection, the payment collection's payment sessions are \ndeleted. It also syncs the payment collection's amount, currency code, and other details with the details in the cart.\n\nThis workflow is used by other cart-related workflows, such as the [refreshCartItemsWorkflow](./page.mdx) to refresh the cart's\npayment collection Line truncated
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"RefreshCartItemsWorkflowInput","type":"[RefreshCartItemsWorkflowInput](../../../../types/core_flows.RefreshCartItemsWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"The details of the cart to refresh.","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"promo_codes","type":"`string`[]","description":"The promotion codes applied on the cart.\nThese promotion codes will replace previously applied codes.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="refreshCartItemsWorkflow"/>
|
||||
|
||||
## Hooks
|
||||
|
||||
Hooks allow you to inject custom functionalities into the workflow. You'll receive data from the workflow, as well as additional data sent through an HTTP request.
|
||||
|
||||
Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/workflow-hooks) and [Additional Data](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).
|
||||
|
||||
### validate
|
||||
|
||||
This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.
|
||||
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
import { addShippingMethodToCartWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
addShippingMethodToCartWorkflow.hooks.validate(
|
||||
(async ({ input, cart }, { container }) => {
|
||||
//TODO
|
||||
})
|
||||
)
|
||||
```
|
||||
|
||||
#### Input
|
||||
|
||||
Handlers consuming this hook accept the following input.
|
||||
|
||||
<TypeList types={[{"name":"input","type":"object","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[AddShippingMethodToCartWorkflowInput](../../../../interfaces/core_flows.AddShippingMethodToCartWorkflowInput/page.mdx)","description":"The data to add a shipping method to a cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The ID of the cart to add the shipping method to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`object`[]","description":"The shipping options to create the shipping methods from and add to the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"cart","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validate"/>
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
---
|
||||
slug: /references/medusa-workflows/refreshCartShippingMethodsWorkflow
|
||||
sidebar_label: refreshCartShippingMethodsWorkflow
|
||||
tags:
|
||||
- query
|
||||
- cart
|
||||
- workflow
|
||||
- remote query
|
||||
- fulfillment
|
||||
---
|
||||
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
# refreshCartShippingMethodsWorkflow - Medusa Core Workflows Reference
|
||||
|
||||
This documentation provides a reference to the `refreshCartShippingMethodsWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow refreshes a cart's shipping methods, ensuring that their associated shipping options can still be used on the cart,
|
||||
and retrieve their correct pricing after a cart update. This workflow is used by the [refreshCartItemsWorkflow](../core_flows.Cart.Workflows_Cart.refreshCartItemsWorkflow/page.mdx).
|
||||
|
||||
You can use this workflow within your own customizations or custom workflows, allowing you to refresh the cart's shipping method after making updates to the cart.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/cart/workflows/refresh-cart-shipping-methods.ts#L48" />
|
||||
|
||||
## Examples
|
||||
|
||||
<CodeTabs group="workflow-exection">
|
||||
<CodeTab label="API Route" value="api-route">
|
||||
|
||||
```ts title="src/api/workflow/route.ts"
|
||||
import type {
|
||||
MedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { refreshCartShippingMethodsWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
export async function POST(
|
||||
req: MedusaRequest,
|
||||
res: MedusaResponse
|
||||
) {
|
||||
const { result } = await refreshCartShippingMethodsWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
cart_id: "cart_123",
|
||||
}
|
||||
})
|
||||
|
||||
res.send(result)
|
||||
}
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
<CodeTab label="Subscriber" value="subscriber">
|
||||
|
||||
```ts title="src/subscribers/order-placed.ts"
|
||||
import {
|
||||
type SubscriberConfig,
|
||||
type SubscriberArgs,
|
||||
} from "@medusajs/framework"
|
||||
import { refreshCartShippingMethodsWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
export default async function handleOrderPlaced({
|
||||
event: { data },
|
||||
container,
|
||||
}: SubscriberArgs < { id: string } > ) {
|
||||
const { result } = await refreshCartShippingMethodsWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
cart_id: "cart_123",
|
||||
}
|
||||
})
|
||||
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
export const config: SubscriberConfig = {
|
||||
event: "order.placed",
|
||||
}
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
<CodeTab label="Scheduled Job" value="scheduled-job">
|
||||
|
||||
```ts title="src/jobs/message-daily.ts"
|
||||
import { MedusaContainer } from "@medusajs/framework/types"
|
||||
import { refreshCartShippingMethodsWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
export default async function myCustomJob(
|
||||
container: MedusaContainer
|
||||
) {
|
||||
const { result } = await refreshCartShippingMethodsWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
cart_id: "cart_123",
|
||||
}
|
||||
})
|
||||
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
export const config = {
|
||||
name: "run-once-a-day",
|
||||
schedule: "0 0 * * *",
|
||||
}
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
<CodeTab label="Another Workflow" value="another-workflow">
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { refreshCartShippingMethodsWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const result = refreshCartShippingMethodsWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
cart_id: "cart_123",
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
</CodeTabs>
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"refreshCartShippingMethodsWorkflow","steps":[{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":1},{"type":"hook","name":"validate","description":"This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.","link":"#validate","depth":2},{"type":"when","condition":"{\n return !!listShippingOptionsInput?.length\n }","depth":"3","steps":[{"type":"workflow","name":"listShippingOptionsForCartWithPricingWorkflow","description":"This workflow lists shipping options that can be used during checkout for a cart. It also retrieves the prices\nof these shipping options, including calculated prices that may be retrieved from third-party providers.\n\nThis workflow is executed in other cart-related workflows, such as [addShippingMethodToCartWorkflow](../core_flows.Cart.Workflows_Cart.addShippingMethodToCartWorkflow/page.mdx) to retrieve the\nprice of the shipping method being added to the cart.\n\nYou can use this workflow within your own customizations or custom workflows, allowing you to retrieve the shipping options of a cart and their prices \nin your custom flows.","link":"../core_flows.Cart.Workflows_Cart.listShippingOptionsForCartWithPricingWorkflow/page.mdx","depth":3},{"type":"step","name":"removeShippingMethodFromCartStep","description":"This step removes shipping methods from a cart.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.removeShippingMethodFromCartStep/page.mdx","depth":3},{"type":"step","name":"updateShippingMethodsStep","description":"This step updates a cart's shipping methods.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.updateShippingMethodsStep/page.mdx","depth":3}]}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"RefreshCartShippingMethodsWorkflowInput","type":"[RefreshCartShippingMethodsWorkflowInput](../../../../types/core_flows.RefreshCartShippingMethodsWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"The details of the cart to refresh.","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="refreshCartShippingMethodsWorkflow"/>
|
||||
|
||||
## Output
|
||||
|
||||
<TypeList types={[{"name":"undefined","type":"`undefined`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"undefined","type":"`undefined`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="refreshCartShippingMethodsWorkflow"/>
|
||||
|
||||
## Hooks
|
||||
|
||||
Hooks allow you to inject custom functionalities into the workflow. You'll receive data from the workflow, as well as additional data sent through an HTTP request.
|
||||
|
||||
Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/workflow-hooks) and [Additional Data](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).
|
||||
|
||||
### validate
|
||||
|
||||
This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.
|
||||
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
import { addShippingMethodToCartWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
addShippingMethodToCartWorkflow.hooks.validate(
|
||||
(async ({ input, cart }, { container }) => {
|
||||
//TODO
|
||||
})
|
||||
)
|
||||
```
|
||||
|
||||
#### Input
|
||||
|
||||
Handlers consuming this hook accept the following input.
|
||||
|
||||
<TypeList types={[{"name":"input","type":"object","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[AddShippingMethodToCartWorkflowInput](../../../../interfaces/core_flows.AddShippingMethodToCartWorkflowInput/page.mdx)","description":"The data to add a shipping method to a cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The ID of the cart to add the shipping method to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`object`[]","description":"The shipping options to create the shipping methods from and add to the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"cart","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validate"/>
|
||||
+48
-8
@@ -14,9 +14,17 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `refreshPaymentCollectionForCartWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow refreshes the payment collections of a cart.
|
||||
This workflow refreshes a cart's payment collection, which is useful once the cart is created or when its details
|
||||
are updated. If the cart's total changes to the amount in its payment collection, the payment collection's payment sessions are
|
||||
deleted. It also syncs the payment collection's amount, currency code, and other details with the details in the cart.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/cart/workflows/refresh-payment-collection.ts#L22" />
|
||||
This workflow is used by other cart-related workflows, such as the [refreshCartItemsWorkflow](../core_flows.Cart.Workflows_Cart.refreshCartItemsWorkflow/page.mdx) to refresh the cart's
|
||||
payment collection after an update.
|
||||
|
||||
You can use this workflow within your own customizations or custom workflows, allowing you to refresh the cart's payment collection after making updates to it in your
|
||||
custom flows.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/cart/workflows/refresh-payment-collection.ts#L52" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -37,7 +45,7 @@ export async function POST(
|
||||
const { result } = await refreshPaymentCollectionForCartWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
}
|
||||
})
|
||||
|
||||
@@ -62,7 +70,7 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await refreshPaymentCollectionForCartWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
}
|
||||
})
|
||||
|
||||
@@ -87,7 +95,7 @@ export default async function myCustomJob(
|
||||
const { result } = await refreshPaymentCollectionForCartWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
}
|
||||
})
|
||||
|
||||
@@ -113,7 +121,7 @@ const myWorkflow = createWorkflow(
|
||||
const result = refreshPaymentCollectionForCartWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -125,8 +133,40 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"refreshPaymentCollectionForCartWorkflow","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":1},{"type":"when","condition":"{\n const valueIsEqual = MathBN.eq(\n cart.payment_collection?.raw_amount ?? -1,\n cart.raw_total\n )\n\n if (valueIsEqual) {\n return cart.payment_collection.currency_code !== cart.currency_code\n }\n\n return true\n }","depth":"2","steps":[{"type":"workflow","name":"deletePaymentSessionsWorkflow","description":"This workflow deletes one or more payment sessions.\n\n","link":"../../../../Payment_Collection/Workflows_Payment_Collection/functions/core_flows.Payment_Collection.Workflows_Payment_Collection.deletePaymentSessionsWorkflow/page.mdx","depth":2},{"type":"step","name":"updatePaymentCollectionStep","description":"This step updates payment collections matching the specified filters.\n\n","link":"../../../../Payment_Collection/Steps_Payment_Collection/functions/core_flows.Payment_Collection.Steps_Payment_Collection.updatePaymentCollectionStep/page.mdx","depth":2}]}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"refreshPaymentCollectionForCartWorkflow","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":1},{"type":"hook","name":"validate","description":"This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.","link":"#validate","depth":2},{"type":"when","condition":"{\n const valueIsEqual = MathBN.eq(\n cart.payment_collection?.raw_amount ?? -1,\n cart.raw_total\n )\n\n if (valueIsEqual) {\n return cart.payment_collection.currency_code !== cart.currency_code\n }\n\n return true\n }","depth":"3","steps":[{"type":"workflow","name":"deletePaymentSessionsWorkflow","description":"This workflow deletes one or more payment sessions. It's used by other workflows, like\nrefreshPaymentCollectionForCartWorkflow to delete payment sessions when the cart's total changes.\n\nYou can use this workflow within your own customizations or custom workflows, allowing you\nto delete payment sessions in your custom flows.","link":"../../../../Payment_Collection/Workflows_Payment_Collection/functions/core_flows.Payment_Collection.Workflows_Payment_Collection.deletePaymentSessionsWorkflow/page.mdx","depth":3},{"type":"step","name":"updatePaymentCollectionStep","description":"This step updates payment collections matching the specified filters.","link":"../../../../Payment_Collection/Steps_Payment_Collection/functions/core_flows.Payment_Collection.Steps_Payment_Collection.updatePaymentCollectionStep/page.mdx","depth":3}]}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"RefreshPaymentCollectionForCartWorklowInput","type":"[RefreshPaymentCollectionForCartWorklowInput](../../../../types/core_flows.RefreshPaymentCollectionForCartWorklowInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="refreshPaymentCollectionForCartWorkflow"/>
|
||||
<TypeList types={[{"name":"RefreshPaymentCollectionForCartWorklowInput","type":"[RefreshPaymentCollectionForCartWorklowInput](../../../../types/core_flows.RefreshPaymentCollectionForCartWorklowInput/page.mdx)","optional":false,"defaultValue":"","description":"The details of the cart to refresh.","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="refreshPaymentCollectionForCartWorkflow"/>
|
||||
|
||||
## Output
|
||||
|
||||
<TypeList types={[{"name":"undefined","type":"`undefined`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"undefined","type":"`undefined`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="refreshPaymentCollectionForCartWorkflow"/>
|
||||
|
||||
## Hooks
|
||||
|
||||
Hooks allow you to inject custom functionalities into the workflow. You'll receive data from the workflow, as well as additional data sent through an HTTP request.
|
||||
|
||||
Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/workflow-hooks) and [Additional Data](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).
|
||||
|
||||
### validate
|
||||
|
||||
This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.
|
||||
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
import { addShippingMethodToCartWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
addShippingMethodToCartWorkflow.hooks.validate(
|
||||
(async ({ input, cart }, { container }) => {
|
||||
//TODO
|
||||
})
|
||||
)
|
||||
```
|
||||
|
||||
#### Input
|
||||
|
||||
Handlers consuming this hook accept the following input.
|
||||
|
||||
<TypeList types={[{"name":"input","type":"object","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[AddShippingMethodToCartWorkflowInput](../../../../interfaces/core_flows.AddShippingMethodToCartWorkflowInput/page.mdx)","description":"The data to add a shipping method to a cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The ID of the cart to add the shipping method to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`object`[]","description":"The shipping options to create the shipping methods from and add to the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"cart","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validate"/>
|
||||
+55
-12
@@ -5,6 +5,13 @@ tags:
|
||||
- query
|
||||
- cart
|
||||
- workflow
|
||||
- remote query
|
||||
- fulfillment
|
||||
- tax
|
||||
- promotion
|
||||
- link
|
||||
- payment
|
||||
- logger
|
||||
---
|
||||
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
@@ -13,9 +20,13 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `transferCartCustomerWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow transfers cart's customer.
|
||||
This workflow transfers a cart's customer ownership to another customer. It's useful if a customer logs in after
|
||||
adding the items to their cart, allowing you to transfer the cart's ownership to the logged-in customer. This workflow is used
|
||||
by the [Set Cart's Customer Store API Route](https://docs.medusajs.com/api/store#carts\_postcartsidcustomer).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/cart/workflows/transfer-cart-customer.ts#L15" />
|
||||
You can use this workflow within your own customizations or custom workflows, allowing you to set the cart's customer within your custom flows.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/cart/workflows/transfer-cart-customer.ts#L50" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -36,8 +47,8 @@ export async function POST(
|
||||
const { result } = await transferCartCustomerWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"id": "id_2QsAtdSaG9b4ARfkN",
|
||||
"customer_id": "{value}"
|
||||
id: "cart_123",
|
||||
customer_id: "cus_123"
|
||||
}
|
||||
})
|
||||
|
||||
@@ -62,8 +73,8 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await transferCartCustomerWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"id": "id_2QsAtdSaG9b4ARfkN",
|
||||
"customer_id": "{value}"
|
||||
id: "cart_123",
|
||||
customer_id: "cus_123"
|
||||
}
|
||||
})
|
||||
|
||||
@@ -88,8 +99,8 @@ export default async function myCustomJob(
|
||||
const { result } = await transferCartCustomerWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"id": "id_2QsAtdSaG9b4ARfkN",
|
||||
"customer_id": "{value}"
|
||||
id: "cart_123",
|
||||
customer_id: "cus_123"
|
||||
}
|
||||
})
|
||||
|
||||
@@ -115,8 +126,8 @@ const myWorkflow = createWorkflow(
|
||||
const result = transferCartCustomerWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"id": "id_2QsAtdSaG9b4ARfkN",
|
||||
"customer_id": "{value}"
|
||||
id: "cart_123",
|
||||
customer_id: "cus_123"
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -128,8 +139,40 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"transferCartCustomerWorkflow","steps":[{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":1},{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":2},{"type":"when","condition":"shouldTransfer","depth":"3","steps":[{"type":"step","name":"updateCartsStep","description":"This step updates a cart.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.updateCartsStep/page.mdx","depth":3}]}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"transferCartCustomerWorkflow","steps":[{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":1},{"type":"hook","name":"validate","description":"This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.","link":"#validate","depth":2},{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":3},{"type":"when","condition":"shouldTransfer","depth":"4","steps":[{"type":"step","name":"updateCartsStep","description":"This step updates a cart.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.updateCartsStep/page.mdx","depth":4},{"type":"workflow","name":"refreshCartItemsWorkflow","description":"This workflow refreshes a cart to ensure its prices, promotion codes, taxes, and other details are applied correctly. It's useful\nafter making a chnge to a cart, such as after adding an item to the cart or adding a promotion code.\n\nThis workflow is used by other cart-related workflows, such as the [addToCartWorkflow](../core_flows.Cart.Workflows_Cart.addToCartWorkflow/page.mdx) after an item\nis added to the cart.\n\nYou can use this workflow within your own customizations or custom workflows, allowing you to refresh the cart after making updates to it in your\ncustom flows.","link":"../core_flows.Cart.Workflows_Cart.refreshCartItemsWorkflow/page.mdx","depth":4}]}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="transferCartCustomerWorkflow"/>
|
||||
<TypeList types={[{"name":"TransferCartCustomerWorkflowInput","type":"[TransferCartCustomerWorkflowInput](../../../../types/core_flows.TransferCartCustomerWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"The cart ownership transfer details.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"The ID of the customer to transfer the cart to.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="transferCartCustomerWorkflow"/>
|
||||
|
||||
## Output
|
||||
|
||||
<TypeList types={[{"name":"undefined","type":"`undefined`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"undefined","type":"`undefined`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="transferCartCustomerWorkflow"/>
|
||||
|
||||
## Hooks
|
||||
|
||||
Hooks allow you to inject custom functionalities into the workflow. You'll receive data from the workflow, as well as additional data sent through an HTTP request.
|
||||
|
||||
Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/workflow-hooks) and [Additional Data](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).
|
||||
|
||||
### validate
|
||||
|
||||
This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.
|
||||
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
import { addShippingMethodToCartWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
addShippingMethodToCartWorkflow.hooks.validate(
|
||||
(async ({ input, cart }, { container }) => {
|
||||
//TODO
|
||||
})
|
||||
)
|
||||
```
|
||||
|
||||
#### Input
|
||||
|
||||
Handlers consuming this hook accept the following input.
|
||||
|
||||
<TypeList types={[{"name":"input","type":"object","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[AddShippingMethodToCartWorkflowInput](../../../../interfaces/core_flows.AddShippingMethodToCartWorkflowInput/page.mdx)","description":"The data to add a shipping method to a cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The ID of the cart to add the shipping method to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`object`[]","description":"The shipping options to create the shipping methods from and add to the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"cart","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validate"/>
|
||||
+56
-8
@@ -15,9 +15,13 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `updateCartPromotionsWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow updates a cart's promotions.
|
||||
This workflow updates a cart's promotions, applying or removing promotion codes from the cart. It also computes the adjustments
|
||||
that need to be applied to the cart's line items and shipping methods based on the promotions applied. This workflow is used by
|
||||
[Add Promotions Store API Route](https://docs.medusajs.com/api/store#carts\_postcartsidpromotions).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/cart/workflows/update-cart-promotions.ts#L34" />
|
||||
You can use this workflow within your own customizations or custom workflows, allowing you to update a cart's promotions within your custom flows.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/cart/workflows/update-cart-promotions.ts#L70" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -38,7 +42,10 @@ export async function POST(
|
||||
const { result } = await updateCartPromotionsWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
promo_codes: ["10OFF"],
|
||||
// imported from @medusajs/framework/utils
|
||||
action: PromotionActions.ADD,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -63,7 +70,10 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await updateCartPromotionsWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
promo_codes: ["10OFF"],
|
||||
// imported from @medusajs/framework/utils
|
||||
action: PromotionActions.ADD,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -88,7 +98,10 @@ export default async function myCustomJob(
|
||||
const { result } = await updateCartPromotionsWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
promo_codes: ["10OFF"],
|
||||
// imported from @medusajs/framework/utils
|
||||
action: PromotionActions.ADD,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -114,7 +127,10 @@ const myWorkflow = createWorkflow(
|
||||
const result = updateCartPromotionsWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
promo_codes: ["10OFF"],
|
||||
// imported from @medusajs/framework/utils
|
||||
action: PromotionActions.ADD,
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -126,8 +142,40 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"updateCartPromotionsWorkflow","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":1},{"type":"step","name":"getPromotionCodesToApply","description":"This step retrieves the promotion codes to apply on a cart.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.getPromotionCodesToApply/page.mdx","depth":2},{"type":"step","name":"getActionsToComputeFromPromotionsStep","description":"This step retrieves the actions to compute based on the promotions\napplied on a cart.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.getActionsToComputeFromPromotionsStep/page.mdx","depth":3},{"type":"step","name":"prepareAdjustmentsFromPromotionActionsStep","description":"This step prepares the line item or shipping method adjustments using\nactions computed by the Promotion Module.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.prepareAdjustmentsFromPromotionActionsStep/page.mdx","depth":4},{"type":"step","name":"removeLineItemAdjustmentsStep","description":"This step removes line item adjustments from a cart.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.removeLineItemAdjustmentsStep/page.mdx","depth":5},{"type":"step","name":"removeShippingMethodAdjustmentsStep","description":"This step removes shipping method adjustments from a cart.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.removeShippingMethodAdjustmentsStep/page.mdx","depth":5},{"type":"step","name":"createLineItemAdjustmentsStep","description":"This step creates line item adjustments in a cart.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.createLineItemAdjustmentsStep/page.mdx","depth":5},{"type":"step","name":"createShippingMethodAdjustmentsStep","description":"This step creates shipping method adjustments for a cart.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.createShippingMethodAdjustmentsStep/page.mdx","depth":5},{"type":"step","name":"updateCartPromotionsStep","description":"This step updates the promotions applied on a cart.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.updateCartPromotionsStep/page.mdx","depth":5}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"updateCartPromotionsWorkflow","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":1},{"type":"hook","name":"validate","description":"This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.","link":"#validate","depth":2},{"type":"step","name":"getPromotionCodesToApply","description":"This step retrieves the promotion codes to apply on a cart.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.getPromotionCodesToApply/page.mdx","depth":3},{"type":"step","name":"getActionsToComputeFromPromotionsStep","description":"This step retrieves the actions to compute based on the promotions\napplied on a cart.\n\n:::tip\n\nYou can use the [retrieveCartStep](../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.retrieveCartStep/page.mdx) to retrieve a cart's details.\n\n:::","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.getActionsToComputeFromPromotionsStep/page.mdx","depth":4},{"type":"step","name":"prepareAdjustmentsFromPromotionActionsStep","description":"This step prepares the line item or shipping method adjustments using\nactions computed by the Promotion Module.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.prepareAdjustmentsFromPromotionActionsStep/page.mdx","depth":5},{"type":"step","name":"removeLineItemAdjustmentsStep","description":"This step removes line item adjustments from a cart.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.removeLineItemAdjustmentsStep/page.mdx","depth":6},{"type":"step","name":"removeShippingMethodAdjustmentsStep","description":"This step removes shipping method adjustments from a cart.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.removeShippingMethodAdjustmentsStep/page.mdx","depth":6},{"type":"step","name":"createLineItemAdjustmentsStep","description":"This step creates line item adjustments in a cart, such as when a promotion is applied.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.createLineItemAdjustmentsStep/page.mdx","depth":6},{"type":"step","name":"createShippingMethodAdjustmentsStep","description":"This step creates shipping method adjustments for a cart.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.createShippingMethodAdjustmentsStep/page.mdx","depth":6},{"type":"step","name":"updateCartPromotionsStep","description":"This step updates the promotions applied on a cart.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.updateCartPromotionsStep/page.mdx","depth":6}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"UpdateCartPromotionsWorkflowInput","type":"[UpdateCartPromotionsWorkflowInput](../../../../types/core_flows.UpdateCartPromotionsWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"promo_codes","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"action","type":"[ADD](../../../../../utils/PromotionUtils/enums/utils.PromotionUtils.PromotionActions/page.mdx#add) \\| [REMOVE](../../../../../utils/PromotionUtils/enums/utils.PromotionUtils.PromotionActions/page.mdx#remove) \\| [REPLACE](../../../../../utils/PromotionUtils/enums/utils.PromotionUtils.PromotionActions/page.mdx#replace)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="updateCartPromotionsWorkflow"/>
|
||||
<TypeList types={[{"name":"UpdateCartPromotionsWorkflowInput","type":"[UpdateCartPromotionsWorkflowInput](../../../../types/core_flows.UpdateCartPromotionsWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"The details of the promotion updates on a cart.","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"promo_codes","type":"`string`[]","description":"The promotion codes to add to the cart, remove from the cart,\nor replace all existing promotions in the cart.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"action","type":"[ADD](../../../../../utils/PromotionUtils/enums/utils.PromotionUtils.PromotionActions/page.mdx#add) \\| [REMOVE](../../../../../utils/PromotionUtils/enums/utils.PromotionUtils.PromotionActions/page.mdx#remove) \\| [REPLACE](../../../../../utils/PromotionUtils/enums/utils.PromotionUtils.PromotionActions/page.mdx#replace)","description":"The action to perform with the specified promotion codes.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="updateCartPromotionsWorkflow"/>
|
||||
|
||||
## Output
|
||||
|
||||
<TypeList types={[{"name":"undefined","type":"`undefined`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"undefined","type":"`undefined`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="updateCartPromotionsWorkflow"/>
|
||||
|
||||
## Hooks
|
||||
|
||||
Hooks allow you to inject custom functionalities into the workflow. You'll receive data from the workflow, as well as additional data sent through an HTTP request.
|
||||
|
||||
Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/workflow-hooks) and [Additional Data](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).
|
||||
|
||||
### validate
|
||||
|
||||
This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.
|
||||
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
import { addShippingMethodToCartWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
addShippingMethodToCartWorkflow.hooks.validate(
|
||||
(async ({ input, cart }, { container }) => {
|
||||
//TODO
|
||||
})
|
||||
)
|
||||
```
|
||||
|
||||
#### Input
|
||||
|
||||
Handlers consuming this hook accept the following input.
|
||||
|
||||
<TypeList types={[{"name":"input","type":"object","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[AddShippingMethodToCartWorkflowInput](../../../../interfaces/core_flows.AddShippingMethodToCartWorkflowInput/page.mdx)","description":"The data to add a shipping method to a cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The ID of the cart to add the shipping method to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`object`[]","description":"The shipping options to create the shipping methods from and add to the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"cart","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validate"/>
|
||||
+33
-5
@@ -10,6 +10,12 @@ tags:
|
||||
- cart
|
||||
- query
|
||||
- workflow
|
||||
- fulfillment
|
||||
- tax
|
||||
- promotion
|
||||
- link
|
||||
- payment
|
||||
- logger
|
||||
---
|
||||
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
@@ -18,7 +24,7 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `updateCartWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow updates a cart and returns it. You can update the cart's region, address, and more. This workflow is executed by the
|
||||
This workflow updates a cart and returns it. You can update the cart's region, address, and more. This workflow is executed by the
|
||||
[Update Cart Store API Route](https://docs.medusajs.com/api/store#carts\_postcartsid).
|
||||
|
||||
:::note
|
||||
@@ -27,12 +33,12 @@ This workflow doesn't allow updating a cart's line items. Instead, use [addToCar
|
||||
|
||||
:::
|
||||
|
||||
This workflow has a hook that allows you to perform custom actions on the updated cart. For example, you can pass custom data under the `additional_data` property of the Update Cart API route,
|
||||
This workflow has a hook that allows you to perform custom actions on the updated cart. For example, you can pass custom data under the `additional_data` property of the Update Cart API route,
|
||||
then update any associated details related to the cart in the workflow's hook.
|
||||
|
||||
You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around updating a cart.
|
||||
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around updating a cart.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/cart/workflows/update-cart.ts#L80" />
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/cart/workflows/update-cart.ts#L82" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -193,7 +199,7 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"updateCartWorkflow","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":1},{"type":"step","name":"findSalesChannelStep","description":"This step either retrieves a sales channel either using the ID provided as an input, or, if no ID\nis provided, the default sales channel of the first store.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.findSalesChannelStep/page.mdx","depth":2},{"type":"step","name":"findOrCreateCustomerStep","description":"This step either finds a customer matching the specified ID, or finds / create a customer\nmatching the specified email. If both ID and email are provided, ID takes precedence.\nIf the customer is a guest, the email is updated to the provided email.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.findOrCreateCustomerStep/page.mdx","depth":2},{"type":"when","condition":"{\n return !!data.input.region_id\n }","depth":"3","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":3}]},{"type":"when","condition":"{\n return !!regionUpdated\n }","depth":"4","steps":[{"type":"step","name":"emitEventStep","description":"Emit an event.\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":4}]},{"type":"step","name":"updateCartsStep","description":"This step updates a cart.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.updateCartsStep/page.mdx","depth":5},{"type":"step","name":"emitEventStep","description":"Emit an event.\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":5},{"type":"when","condition":"{\n return !!regionUpdated\n }","depth":"6","steps":[{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":6},{"type":"step","name":"deleteLineItemsStep","description":"This step deletes line items.\n\n","link":"../../../../Line_Item/Steps_Line_Item/functions/core_flows.Line_Item.Steps_Line_Item.deleteLineItemsStep/page.mdx","depth":6}]},{"type":"hook","name":"cartUpdated","description":"This hook is executed after a cart is update. You can consume this hook to perform custom actions on the updated cart.\n\n","link":"#cartUpdated","depth":7}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"updateCartWorkflow","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":1},{"type":"step","name":"findSalesChannelStep","description":"This step either retrieves a sales channel either using the ID provided as an input, or, if no ID\nis provided, the default sales channel of the first store.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.findSalesChannelStep/page.mdx","depth":2},{"type":"step","name":"findOrCreateCustomerStep","description":"This step either finds a customer matching the specified ID, or finds / create a customer\nmatching the specified email. If both ID and email are provided, ID takes precedence.\nIf the customer is a guest, the email is updated to the provided email.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.findOrCreateCustomerStep/page.mdx","depth":2},{"type":"when","condition":"{\n return !!data.input.region_id\n }","depth":"3","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":3}]},{"type":"hook","name":"validate","description":"This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.","link":"#validate","depth":4},{"type":"when","condition":"{\n return !!regionUpdated\n }","depth":"5","steps":[{"type":"step","name":"emitEventStep","description":"Emit an event.","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":5}]},{"type":"step","name":"updateCartsStep","description":"This step updates a cart.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.updateCartsStep/page.mdx","depth":6},{"type":"step","name":"emitEventStep","description":"Emit an event.","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":6},{"type":"when","condition":"{\n return !!regionUpdated\n }","depth":"7","steps":[{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":7},{"type":"step","name":"deleteLineItemsStep","description":"This step deletes line items.","link":"../../../../Line_Item/Steps_Line_Item/functions/core_flows.Line_Item.Steps_Line_Item.deleteLineItemsStep/page.mdx","depth":7}]},{"type":"workflow","name":"refreshCartItemsWorkflow","description":"This workflow refreshes a cart to ensure its prices, promotion codes, taxes, and other details are applied correctly. It's useful\nafter making a chnge to a cart, such as after adding an item to the cart or adding a promotion code.\n\nThis workflow is used by other cart-related workflows, such as the [addToCartWorkflow](../core_flows.Cart.Workflows_Cart.addToCartWorkflow/page.mdx) after an item\nis added to the cart.\n\nYou can use this workflow within your own customizations or custom workflows, allowing you to refresh the cart after making updates to it in your\ncustom flows.","link":"../core_flows.Cart.Workflows_Cart.refreshCartItemsWorkflow/page.mdx","depth":8},{"type":"hook","name":"cartUpdated","description":"This hook is executed after a cart is update. You can consume this hook to perform custom actions on the updated cart.","link":"#cartUpdated","depth":9}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
@@ -209,6 +215,28 @@ Hooks allow you to inject custom functionalities into the workflow. You'll recei
|
||||
|
||||
Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/workflow-hooks) and [Additional Data](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).
|
||||
|
||||
### validate
|
||||
|
||||
This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.
|
||||
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
import { addShippingMethodToCartWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
addShippingMethodToCartWorkflow.hooks.validate(
|
||||
(async ({ input, cart }, { container }) => {
|
||||
//TODO
|
||||
})
|
||||
)
|
||||
```
|
||||
|
||||
#### Input
|
||||
|
||||
Handlers consuming this hook accept the following input.
|
||||
|
||||
<TypeList types={[{"name":"input","type":"object","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[AddShippingMethodToCartWorkflowInput](../../../../interfaces/core_flows.AddShippingMethodToCartWorkflowInput/page.mdx)","description":"The data to add a shipping method to a cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The ID of the cart to add the shipping method to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`object`[]","description":"The shipping options to create the shipping methods from and add to the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"cart","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validate"/>
|
||||
|
||||
### cartUpdated
|
||||
|
||||
This hook is executed after a cart is update. You can consume this hook to perform custom actions on the updated cart.
|
||||
|
||||
+64
-15
@@ -7,6 +7,12 @@ tags:
|
||||
- cart
|
||||
- workflow
|
||||
- inventory
|
||||
- fulfillment
|
||||
- tax
|
||||
- promotion
|
||||
- link
|
||||
- payment
|
||||
- logger
|
||||
---
|
||||
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
@@ -15,9 +21,12 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `updateLineItemInCartWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow updates a cart's line item.
|
||||
This workflow updates a line item's details in a cart. You can update the line item's quantity, unit price, and more. This workflow is executed
|
||||
by the [Update Line Item Store API Route](https://docs.medusajs.com/api/store#carts\_postcartsidlineitemsline\_id).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/cart/workflows/update-line-item-in-cart.ts#L27" />
|
||||
You can use this workflow within your own customizations or custom workflows, allowing you to update a line item's details in your custom flows.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/cart/workflows/update-line-item-in-cart.ts#L50" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -38,9 +47,11 @@ export async function POST(
|
||||
const { result } = await updateLineItemInCartWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}",
|
||||
"item_id": "{value}",
|
||||
"update": "{value}"
|
||||
cart_id: "cart_123",
|
||||
item_id: "item_123",
|
||||
update: {
|
||||
quantity: 2
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -65,9 +76,11 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await updateLineItemInCartWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}",
|
||||
"item_id": "{value}",
|
||||
"update": "{value}"
|
||||
cart_id: "cart_123",
|
||||
item_id: "item_123",
|
||||
update: {
|
||||
quantity: 2
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -92,9 +105,11 @@ export default async function myCustomJob(
|
||||
const { result } = await updateLineItemInCartWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}",
|
||||
"item_id": "{value}",
|
||||
"update": "{value}"
|
||||
cart_id: "cart_123",
|
||||
item_id: "item_123",
|
||||
update: {
|
||||
quantity: 2
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -120,9 +135,11 @@ const myWorkflow = createWorkflow(
|
||||
const result = updateLineItemInCartWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"cart_id": "{value}",
|
||||
"item_id": "{value}",
|
||||
"update": "{value}"
|
||||
cart_id: "cart_123",
|
||||
item_id: "item_123",
|
||||
update: {
|
||||
quantity: 2
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -134,8 +151,40 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"updateLineItemInCartWorkflow","steps":[{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":1},{"type":"when","condition":"{\n return !!variantIds.length\n }","depth":"2","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":2}]},{"type":"step","name":"validateVariantPricesStep","description":"This step validates the specified variant objects to ensure they have prices.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateVariantPricesStep/page.mdx","depth":3},{"type":"workflow","name":"confirmVariantInventoryWorkflow","description":"This workflow confirms for one or more variants that their inventory has a required quantity.\n\n","link":"../core_flows.Cart.Workflows_Cart.confirmVariantInventoryWorkflow/page.mdx","depth":4},{"type":"step","name":"updateLineItemsStepWithSelector","description":"This step updates line items.\n\n","link":"../../../../Line_Item/Steps_Line_Item/functions/core_flows.Line_Item.Steps_Line_Item.updateLineItemsStepWithSelector/page.mdx","depth":5}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"updateLineItemInCartWorkflow","steps":[{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":1},{"type":"step","name":"validateCartStep","description":"This step validates a cart to ensure it exists and is not completed.\nIf not valid, the step throws an error.\n\n:::tip\n\nYou can use the [retrieveCartStep](../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.retrieveCartStep/page.mdx) to retrieve a cart's details.\n\n:::","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateCartStep/page.mdx","depth":2},{"type":"hook","name":"validate","description":"This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.","link":"#validate","depth":3},{"type":"when","condition":"{\n return !!variantIds.length\n }","depth":"4","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":4}]},{"type":"step","name":"validateVariantPricesStep","description":"This step validates the specified variant objects to ensure they have prices.\nIf not valid, the step throws an error.","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateVariantPricesStep/page.mdx","depth":5},{"type":"workflow","name":"confirmVariantInventoryWorkflow","description":"This workflow validates that product variants are in-stock at the specified sales channel, before adding them or updating their quantity in the cart. If a variant doesn't have sufficient quantity in-stock,\nthe workflow throws an error. If all variants have sufficient inventory, the workflow returns the cart's items with their inventory details.\n\nThis workflow is useful when confirming that a product variant has sufficient quantity to be added to or updated in the cart. It's executed\nby other cart-related workflows, such as [addToCartWorkflow](../core_flows.Cart.Workflows_Cart.addToCartWorkflow/page.mdx), to confirm that a product variant can be added to the cart at the specified quantity.\n\n:::note\n\nLearn more about the links between the product variant and sales channels and inventory items in [this documentation](https://docs.medusajs.com/resources/commerce-modules/product/links-to-other-modules).\n\n:::\n\nYou can use this workflow within your own customizations or custom workflows, allowing you to check whether a product variant has enough inventory quantity before adding them to the cart.","link":"../core_flows.Cart.Workflows_Cart.confirmVariantInventoryWorkflow/page.mdx","depth":6},{"type":"step","name":"updateLineItemsStepWithSelector","description":"This step updates line items.","link":"../../../../Line_Item/Steps_Line_Item/functions/core_flows.Line_Item.Steps_Line_Item.updateLineItemsStepWithSelector/page.mdx","depth":7},{"type":"workflow","name":"refreshCartItemsWorkflow","description":"This workflow refreshes a cart to ensure its prices, promotion codes, taxes, and other details are applied correctly. It's useful\nafter making a chnge to a cart, such as after adding an item to the cart or adding a promotion code.\n\nThis workflow is used by other cart-related workflows, such as the [addToCartWorkflow](../core_flows.Cart.Workflows_Cart.addToCartWorkflow/page.mdx) after an item\nis added to the cart.\n\nYou can use this workflow within your own customizations or custom workflows, allowing you to refresh the cart after making updates to it in your\ncustom flows.","link":"../core_flows.Cart.Workflows_Cart.refreshCartItemsWorkflow/page.mdx","depth":8}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"UpdateLineItemInCartWorkflowInputDTO","type":"[UpdateLineItemInCartWorkflowInputDTO](../../../../../types/interfaces/types.UpdateLineItemInCartWorkflowInputDTO/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"update","type":"Partial<[UpdateLineItemDTO](../../../../../cart/interfaces/cart.UpdateLineItemDTO/page.mdx)>","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`string`","description":"The subtitle of the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`string`","description":"The thumbnail of the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`string`","description":"The associated cart's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`string`","description":"The associated product's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_title","type":"`string`","description":"The title of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_description","type":"`string`","description":"The description of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_subtitle","type":"`string`","description":"The subtitle of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_type","type":"`string`","description":"The type of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_type_id","type":"`string`","description":"The ID of type of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_collection","type":"`string`","description":"The collection of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_handle","type":"`string`","description":"The handle of the associated product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_id","type":"`string`","description":"The associated variant's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_sku","type":"`string`","description":"The SKU of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_barcode","type":"`string`","description":"The barcode of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_title","type":"`string`","description":"The title of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_option_values","type":"`Record<string, unknown>`","description":"The option values of the associated variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Whether the line item requires shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_discountable","type":"`boolean`","description":"Whether the line item is discountable.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_tax_inclusive","type":"`boolean`","description":"Whether the line item's amount is tax inclusive.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_custom_price","type":"`boolean`","description":"Whether the line item's amount is a custom price.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"compare_at_unit_price","type":"[BigNumberInput](../../../../../cart/types/cart.BigNumberInput/page.mdx)","description":"The calculated price of the line item after applying promotions.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":fLine truncated
|
||||
|
||||
## Output
|
||||
|
||||
<TypeList types={[{"name":"undefined","type":"`undefined`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"undefined","type":"`undefined`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="updateLineItemInCartWorkflow"/>
|
||||
|
||||
## Hooks
|
||||
|
||||
Hooks allow you to inject custom functionalities into the workflow. You'll receive data from the workflow, as well as additional data sent through an HTTP request.
|
||||
|
||||
Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/workflow-hooks) and [Additional Data](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).
|
||||
|
||||
### validate
|
||||
|
||||
This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.
|
||||
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
import { addShippingMethodToCartWorkflow } from "@medusajs/medusa/core-flows"
|
||||
|
||||
addShippingMethodToCartWorkflow.hooks.validate(
|
||||
(async ({ input, cart }, { container }) => {
|
||||
//TODO
|
||||
})
|
||||
)
|
||||
```
|
||||
|
||||
#### Input
|
||||
|
||||
Handlers consuming this hook accept the following input.
|
||||
|
||||
<TypeList types={[{"name":"input","type":"object","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[AddShippingMethodToCartWorkflowInput](../../../../interfaces/core_flows.AddShippingMethodToCartWorkflowInput/page.mdx)","description":"The data to add a shipping method to a cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The ID of the cart to add the shipping method to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`object`[]","description":"The shipping options to create the shipping methods from and add to the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"cart","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validate"/>
|
||||
+11
-8
@@ -14,9 +14,12 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `updateTaxLinesWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow updates a cart's tax lines.
|
||||
This workflow updates a cart's tax lines that are applied on line items and shipping methods. You can update the line item's quantity, unit price, and more. This workflow is executed
|
||||
by the [Calculate Taxes Store API Route](https://docs.medusajs.com/api/store#carts\_postcartsidtaxes).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/cart/workflows/update-tax-lines.ts#L74" />
|
||||
You can use this workflow within your own customizations or custom workflows, allowing you to update a cart's tax lines in your custom flows.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/cart/workflows/update-tax-lines.ts#L118" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -37,7 +40,7 @@ export async function POST(
|
||||
const { result } = await updateTaxLinesWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
}
|
||||
})
|
||||
|
||||
@@ -62,7 +65,7 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await updateTaxLinesWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
}
|
||||
})
|
||||
|
||||
@@ -87,7 +90,7 @@ export default async function myCustomJob(
|
||||
const { result } = await updateTaxLinesWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
}
|
||||
})
|
||||
|
||||
@@ -113,7 +116,7 @@ const myWorkflow = createWorkflow(
|
||||
const result = updateTaxLinesWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"cart_id": "{value}"
|
||||
cart_id: "cart_123",
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -125,8 +128,8 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"updateTaxLinesWorkflow","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":1},{"type":"step","name":"getItemTaxLinesStep","description":"This step retrieves the tax lines for an order's line items and shipping methods.\n\n","link":"../../../../Tax/Steps_Tax/functions/core_flows.Tax.Steps_Tax.getItemTaxLinesStep/page.mdx","depth":2},{"type":"step","name":"setTaxLinesForItemsStep","description":"This step sets the tax lines of shipping methods and line items in a cart.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.setTaxLinesForItemsStep/page.mdx","depth":3}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"updateTaxLinesWorkflow","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":1},{"type":"step","name":"getItemTaxLinesStep","description":"This step retrieves the tax lines for an order or cart's line items and shipping methods.\n\n:::note\n\nYou can retrieve an order, cart, item, shipping method, and address details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query),\nor [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep).\n\n:::","link":"../../../../Tax/Steps_Tax/functions/core_flows.Tax.Steps_Tax.getItemTaxLinesStep/page.mdx","depth":2},{"type":"step","name":"setTaxLinesForItemsStep","description":"This step sets the tax lines of shipping methods and line items in a cart.\n\n:::tip\n\nYou can use the [retrieveCartStep](../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.retrieveCartStep/page.mdx) to retrieve a cart's details.\n\n:::","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.setTaxLinesForItemsStep/page.mdx","depth":3}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"UpdateTaxLinesWorkflowInput","type":"[UpdateTaxLinesWorkflowInput](../../../../types/core_flows.UpdateTaxLinesWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[CartLineItemDTO](../../../../../cart/interfaces/cart.CartLineItemDTO/page.mdx)[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"original_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original subtotal of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original tax total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item subtotal of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item tax total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.Line truncated
|
||||
<TypeList types={[{"name":"UpdateTaxLinesWorkflowInput","type":"[UpdateTaxLinesWorkflowInput](../../../../types/core_flows.UpdateTaxLinesWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"The details of the cart to update tax lines for.","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[CartLineItemDTO](../../../../../cart/interfaces/cart.CartLineItemDTO/page.mdx)[]","description":"The items to update their tax lines.\nIf not specified, taxes are updated for all of the cart's\nline items.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"original_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original subtotal of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original tax total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item subtotal of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item tax total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The total of the cart line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","descriptionLine truncated
|
||||
+18
-147
@@ -12,157 +12,28 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
This documentation provides a reference to the `validateExistingPaymentCollectionStep`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This step validates that a cart doesn't have a payment collection.
|
||||
If the cart has a payment collection, the step throws an error.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { validateExistingPaymentCollectionStep } from "@medusajs/medusa/core-flows"
|
||||
:::tip
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = validateExistingPaymentCollectionStep({
|
||||
"cart": {
|
||||
"id": "id_6KeDjKcLAixlmaV",
|
||||
"currency_code": "{value}",
|
||||
"original_item_total": {
|
||||
"numeric": 29
|
||||
},
|
||||
"original_item_subtotal": {
|
||||
"numeric": 3
|
||||
},
|
||||
"original_item_tax_total": {
|
||||
"numeric": 5
|
||||
},
|
||||
"item_total": {
|
||||
"numeric": 28
|
||||
},
|
||||
"item_subtotal": {
|
||||
"numeric": 3
|
||||
},
|
||||
"item_tax_total": {
|
||||
"numeric": 8
|
||||
},
|
||||
"original_total": {
|
||||
"numeric": 12
|
||||
},
|
||||
"original_subtotal": {
|
||||
"numeric": 31
|
||||
},
|
||||
"original_tax_total": {
|
||||
"numeric": 36
|
||||
},
|
||||
"total": {
|
||||
"numeric": 32
|
||||
},
|
||||
"subtotal": {
|
||||
"numeric": 11
|
||||
},
|
||||
"tax_total": {
|
||||
"numeric": 13
|
||||
},
|
||||
"discount_total": {
|
||||
"numeric": 45
|
||||
},
|
||||
"discount_tax_total": {
|
||||
"numeric": 37
|
||||
},
|
||||
"gift_card_total": {
|
||||
"numeric": 17
|
||||
},
|
||||
"gift_card_tax_total": {
|
||||
"numeric": 12
|
||||
},
|
||||
"shipping_total": {
|
||||
"numeric": 39
|
||||
},
|
||||
"shipping_subtotal": {
|
||||
"numeric": 21
|
||||
},
|
||||
"shipping_tax_total": {
|
||||
"numeric": 24
|
||||
},
|
||||
"original_shipping_total": {
|
||||
"numeric": 41
|
||||
},
|
||||
"original_shipping_subtotal": {
|
||||
"numeric": 17
|
||||
},
|
||||
"original_shipping_tax_total": {
|
||||
"numeric": 1
|
||||
},
|
||||
"raw_original_item_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_item_subtotal": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_item_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_item_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_item_subtotal": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_item_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_subtotal": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_subtotal": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_discount_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_discount_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_gift_card_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_gift_card_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_shipping_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_shipping_subtotal": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_shipping_tax_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_shipping_total": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_shipping_subtotal": {
|
||||
"value": "{value}"
|
||||
},
|
||||
"raw_original_shipping_tax_total": {
|
||||
"value": "{value}"
|
||||
}
|
||||
}
|
||||
})
|
||||
You can use the retrieveCartStep to retrieve a cart's details.
|
||||
|
||||
:::
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
const data = validateExistingPaymentCollectionStep({
|
||||
cart: {
|
||||
// other cart details...
|
||||
payment_collection: {
|
||||
id: "paycol_123",
|
||||
// other payment collection details.
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"cart","type":"[CartDTO](../../../../../cart/interfaces/cart.CartDTO/page.mdx) & `object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the cart","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_item_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item subtotal of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_item_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item tax total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item subtotal of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item tax total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}Line truncated
|
||||
<TypeList types={[{"name":"ValidateExistingPaymentCollectionStepInput","type":"[ValidateExistingPaymentCollectionStepInput](../../../../types/core_flows.ValidateExistingPaymentCollectionStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"cart","type":"[CartDTO](../../../../../cart/interfaces/cart.CartDTO/page.mdx) & `object`","description":"The cart to validate.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the cart","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_item_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item subtotal of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_item_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original item tax total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item subtotal of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"item_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item tax total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../cart/types/cart.BigNumberRawValue/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"`BigNumber`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeriLine truncated
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
# refreshCartItemsWorkflowId
|
||||
|
||||
`Const` **refreshCartItemsWorkflowId**: `"refresh-cart-items"`
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
# refreshCartShippingMethodsWorkflowId
|
||||
|
||||
`Const` **refreshCartShippingMethodsWorkflowId**: `"refresh-cart-shipping-methods"`
|
||||
@@ -27,6 +27,11 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
- [updateCartPromotionsStep](../Steps_Cart/functions/core_flows.Cart.Steps_Cart.updateCartPromotionsStep/page.mdx)
|
||||
- [updateCartsStep](../Steps_Cart/functions/core_flows.Cart.Steps_Cart.updateCartsStep/page.mdx)
|
||||
- [updateLineItemsStep](../Steps_Cart/functions/core_flows.Cart.Steps_Cart.updateLineItemsStep/page.mdx)
|
||||
- [updateShippingMethodsStep](../Steps_Cart/functions/core_flows.Cart.Steps_Cart.updateShippingMethodsStep/page.mdx)
|
||||
- [validateAndReturnShippingMethodsDataStep](../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateAndReturnShippingMethodsDataStep/page.mdx)
|
||||
- [validateCartPaymentsStep](../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateCartPaymentsStep/page.mdx)
|
||||
- [validateCartShippingOptionsPriceStep](../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateCartShippingOptionsPriceStep/page.mdx)
|
||||
- [validateCartShippingOptionsStep](../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateCartShippingOptionsStep/page.mdx)
|
||||
- [validateCartStep](../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateCartStep/page.mdx)
|
||||
- [validateLineItemPricesStep](../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateLineItemPricesStep/page.mdx)
|
||||
- [validateVariantPricesStep](../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateVariantPricesStep/page.mdx)
|
||||
@@ -10,6 +10,8 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
- [createPaymentCollectionForCartWorkflow](../Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.createPaymentCollectionForCartWorkflow/page.mdx)
|
||||
- [listShippingOptionsForCartWithPricingWorkflow](../Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.listShippingOptionsForCartWithPricingWorkflow/page.mdx)
|
||||
- [listShippingOptionsForCartWorkflow](../Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.listShippingOptionsForCartWorkflow/page.mdx)
|
||||
- [refreshCartItemsWorkflow](../Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.refreshCartItemsWorkflow/page.mdx)
|
||||
- [refreshCartShippingMethodsWorkflow](../Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.refreshCartShippingMethodsWorkflow/page.mdx)
|
||||
- [refreshPaymentCollectionForCartWorkflow](../Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.refreshPaymentCollectionForCartWorkflow/page.mdx)
|
||||
- [transferCartCustomerWorkflow](../Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.transferCartCustomerWorkflow/page.mdx)
|
||||
- [updateCartPromotionsWorkflow](../Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.updateCartPromotionsWorkflow/page.mdx)
|
||||
|
||||
+8
-23
@@ -19,29 +19,14 @@ Learn more in the [Remote Link documentation.](https://docs.medusajs.com/learn/f
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
createWorkflow
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
import {
|
||||
createRemoteLinkStep
|
||||
} from "@medusajs/medusa/core-flows"
|
||||
import {
|
||||
Modules
|
||||
} from "@medusajs/framework/utils"
|
||||
|
||||
const helloWorldWorkflow = createWorkflow(
|
||||
"hello-world",
|
||||
() => {
|
||||
createRemoteLinkStep([{
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_123",
|
||||
},
|
||||
}])
|
||||
}
|
||||
)
|
||||
createRemoteLinkStep([{
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_123",
|
||||
},
|
||||
}])
|
||||
```
|
||||
|
||||
## Input
|
||||
|
||||
+8
-23
@@ -19,29 +19,14 @@ Learn more in the [Remote Link documentation.](https://docs.medusajs.com/learn/f
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
createWorkflow
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
import {
|
||||
dismissRemoteLinkStep
|
||||
} from "@medusajs/medusa/core-flows"
|
||||
import {
|
||||
Modules
|
||||
} from "@medusajs/framework/utils"
|
||||
|
||||
const helloWorldWorkflow = createWorkflow(
|
||||
"hello-world",
|
||||
() => {
|
||||
dismissRemoteLinkStep([{
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_123",
|
||||
},
|
||||
}])
|
||||
}
|
||||
)
|
||||
dismissRemoteLinkStep([{
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_123",
|
||||
},
|
||||
}])
|
||||
```
|
||||
|
||||
## Input
|
||||
|
||||
+5
-17
@@ -17,24 +17,12 @@ Emit an event.
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
createWorkflow
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
import {
|
||||
emitEventStep
|
||||
} from "@medusajs/medusa/core-flows"
|
||||
|
||||
const helloWorldWorkflow = createWorkflow(
|
||||
"hello-world",
|
||||
() => {
|
||||
emitEventStep({
|
||||
eventName: "custom.created",
|
||||
data: {
|
||||
id: "123"
|
||||
}
|
||||
})
|
||||
emitEventStep({
|
||||
eventName: "custom.created",
|
||||
data: {
|
||||
id: "123"
|
||||
}
|
||||
)
|
||||
})
|
||||
```
|
||||
|
||||
## Input
|
||||
|
||||
+5
-20
@@ -19,26 +19,11 @@ Learn more in the [Remote Link documentation](https://docs.medusajs.com/learn/fu
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
createWorkflow
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
import {
|
||||
removeRemoteLinkStep
|
||||
} from "@medusajs/medusa/core-flows"
|
||||
import {
|
||||
Modules
|
||||
} from "@medusajs/framework/utils"
|
||||
|
||||
const helloWorldWorkflow = createWorkflow(
|
||||
"hello-world",
|
||||
() => {
|
||||
removeRemoteLinkStep([{
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
}])
|
||||
}
|
||||
)
|
||||
removeRemoteLinkStep([{
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
}])
|
||||
```
|
||||
|
||||
## Input
|
||||
|
||||
+20
-11
@@ -12,20 +12,29 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `updateRemoteLinksStep`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { updateRemoteLinksStep } from "@medusajs/medusa/core-flows"
|
||||
This step updates remote links between two records of linked data models.
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = updateRemoteLinksStep([
|
||||
{}
|
||||
])
|
||||
Learn more in the [Remote Link documentation.](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#create-link).
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
const data = updateRemoteLinksStep([
|
||||
{
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_321",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_321",
|
||||
},
|
||||
data: {
|
||||
metadata: {
|
||||
test: false
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
])
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
|
||||
+7
-19
@@ -21,25 +21,13 @@ Learn more in the [Query documentation](https://docs.medusajs.com/learn/fundamen
|
||||
To retrieve a list of records of a data model:
|
||||
|
||||
```ts
|
||||
import {
|
||||
createWorkflow
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
import {
|
||||
useQueryGraphStep
|
||||
} from "@medusajs/medusa/core-flows"
|
||||
|
||||
const helloWorldWorkflow = createWorkflow(
|
||||
"hello-world",
|
||||
() => {
|
||||
const { data: products } = useQueryGraphStep({
|
||||
entity: "product",
|
||||
fields: [
|
||||
"*",
|
||||
"variants.*"
|
||||
]
|
||||
})
|
||||
}
|
||||
)
|
||||
const { data: products } = useQueryGraphStep({
|
||||
entity: "product",
|
||||
fields: [
|
||||
"*",
|
||||
"variants.*"
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
To retrieve a single item instead of a an array:
|
||||
|
||||
+34
-70
@@ -27,86 +27,50 @@ This step is deprecated. Use [useQueryGraphStep](../core_flows.Common.Steps_Comm
|
||||
To retrieve a list of records of a data model:
|
||||
|
||||
```ts
|
||||
import {
|
||||
createWorkflow
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
import {
|
||||
useRemoteQueryStep
|
||||
} from "@medusajs/medusa/core-flows"
|
||||
|
||||
const helloWorldWorkflow = createWorkflow(
|
||||
"hello-world",
|
||||
() => {
|
||||
const products = useRemoteQueryStep({
|
||||
entry_point: "product",
|
||||
fields: [
|
||||
"*",
|
||||
"variants.*"
|
||||
]
|
||||
})
|
||||
}
|
||||
)
|
||||
const products = useRemoteQueryStep({
|
||||
entry_point: "product",
|
||||
fields: [
|
||||
"*",
|
||||
"variants.*"
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
To retrieve a single item instead of a an array:
|
||||
|
||||
```ts
|
||||
import {
|
||||
createWorkflow
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
import {
|
||||
useRemoteQueryStep
|
||||
} from "@medusajs/core-flows"
|
||||
|
||||
const helloWorldWorkflow = createWorkflow(
|
||||
"hello-world",
|
||||
() => {
|
||||
const product = useRemoteQueryStep({
|
||||
entry_point: "product",
|
||||
fields: [
|
||||
"*",
|
||||
"variants.*"
|
||||
],
|
||||
variables: {
|
||||
filters: {
|
||||
id: "123"
|
||||
}
|
||||
},
|
||||
list: false
|
||||
})
|
||||
}
|
||||
)
|
||||
const product = useRemoteQueryStep({
|
||||
entry_point: "product",
|
||||
fields: [
|
||||
"*",
|
||||
"variants.*"
|
||||
],
|
||||
variables: {
|
||||
filters: {
|
||||
id: "123"
|
||||
}
|
||||
},
|
||||
list: false
|
||||
})
|
||||
```
|
||||
|
||||
To throw an error if a record isn't found matching the specified ID:
|
||||
|
||||
```ts
|
||||
import {
|
||||
createWorkflow
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
import {
|
||||
useRemoteQueryStep
|
||||
} from "@medusajs/core-flows"
|
||||
|
||||
const helloWorldWorkflow = createWorkflow(
|
||||
"hello-world",
|
||||
() => {
|
||||
const product = useRemoteQueryStep({
|
||||
entry_point: "product",
|
||||
fields: [
|
||||
"*",
|
||||
"variants.*"
|
||||
],
|
||||
variables: {
|
||||
filters: {
|
||||
id: "123"
|
||||
}
|
||||
},
|
||||
list: false,
|
||||
throw_if_key_not_found: true
|
||||
})
|
||||
}
|
||||
)
|
||||
const product = useRemoteQueryStep({
|
||||
entry_point: "product",
|
||||
fields: [
|
||||
"*",
|
||||
"variants.*"
|
||||
],
|
||||
variables: {
|
||||
filters: {
|
||||
id: "123"
|
||||
}
|
||||
},
|
||||
list: false,
|
||||
throw_if_key_not_found: true
|
||||
})
|
||||
```
|
||||
|
||||
## Input
|
||||
|
||||
+131
-6
@@ -14,7 +14,12 @@ This documentation provides a reference to the `batchLinksWorkflow`. It belongs
|
||||
|
||||
This workflow manages one or more links to create, update, or dismiss them.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/common/workflows/batch-links.ts#L16" />
|
||||
You can use this workflow within your customizations or your own custom workflows, allowing you to
|
||||
manage links within your custom flows.
|
||||
|
||||
Learn more about links in [this documentation](https://docs.medusajs.com/learn/fundamentals/module-links/link).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/common/workflows/batch-links.ts#L67" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -34,7 +39,37 @@ export async function POST(
|
||||
) {
|
||||
const { result } = await batchLinksWorkflow(req.scope)
|
||||
.run({
|
||||
input: {}
|
||||
input: {
|
||||
create: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_123",
|
||||
},
|
||||
}],
|
||||
update: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_321",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_321",
|
||||
},
|
||||
data: {
|
||||
metadata: {
|
||||
test: false
|
||||
}
|
||||
}
|
||||
}],
|
||||
delete: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_321",
|
||||
},
|
||||
}]
|
||||
}
|
||||
})
|
||||
|
||||
res.send(result)
|
||||
@@ -57,7 +92,37 @@ export default async function handleOrderPlaced({
|
||||
}: SubscriberArgs < { id: string } > ) {
|
||||
const { result } = await batchLinksWorkflow(container)
|
||||
.run({
|
||||
input: {}
|
||||
input: {
|
||||
create: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_123",
|
||||
},
|
||||
}],
|
||||
update: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_321",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_321",
|
||||
},
|
||||
data: {
|
||||
metadata: {
|
||||
test: false
|
||||
}
|
||||
}
|
||||
}],
|
||||
delete: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_321",
|
||||
},
|
||||
}]
|
||||
}
|
||||
})
|
||||
|
||||
console.log(result)
|
||||
@@ -80,7 +145,37 @@ export default async function myCustomJob(
|
||||
) {
|
||||
const { result } = await batchLinksWorkflow(container)
|
||||
.run({
|
||||
input: {}
|
||||
input: {
|
||||
create: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_123",
|
||||
},
|
||||
}],
|
||||
update: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_321",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_321",
|
||||
},
|
||||
data: {
|
||||
metadata: {
|
||||
test: false
|
||||
}
|
||||
}
|
||||
}],
|
||||
delete: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_321",
|
||||
},
|
||||
}]
|
||||
}
|
||||
})
|
||||
|
||||
console.log(result)
|
||||
@@ -104,7 +199,37 @@ const myWorkflow = createWorkflow(
|
||||
() => {
|
||||
const result = batchLinksWorkflow
|
||||
.runAsStep({
|
||||
input: {}
|
||||
input: {
|
||||
create: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_123",
|
||||
},
|
||||
}],
|
||||
update: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_321",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_321",
|
||||
},
|
||||
data: {
|
||||
metadata: {
|
||||
test: false
|
||||
}
|
||||
}
|
||||
}],
|
||||
delete: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_321",
|
||||
},
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
@@ -115,7 +240,7 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"batchLinksWorkflow","steps":[{"type":"step","name":"createRemoteLinkStep","description":"This step creates remote links between two records of linked data models.\n\nLearn more in the [Remote Link documentation.](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#create-link).\n\n","link":"../../../Steps_Common/functions/core_flows.Common.Steps_Common.createRemoteLinkStep/page.mdx","depth":1},{"type":"step","name":"updateRemoteLinksStep","description":"\n\n","link":"../../../Steps_Common/functions/core_flows.Common.Steps_Common.updateRemoteLinksStep/page.mdx","depth":1},{"type":"step","name":"dismissRemoteLinkStep","description":"This step removes remote links between two records of linked data models.\n\nLearn more in the [Remote Link documentation.](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#dismiss-link).\n\n","link":"../../../Steps_Common/functions/core_flows.Common.Steps_Common.dismissRemoteLinkStep/page.mdx","depth":1}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"batchLinksWorkflow","steps":[{"type":"step","name":"createRemoteLinkStep","description":"This step creates remote links between two records of linked data models.\n\nLearn more in the [Remote Link documentation.](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#create-link).","link":"../../../Steps_Common/functions/core_flows.Common.Steps_Common.createRemoteLinkStep/page.mdx","depth":1},{"type":"step","name":"updateRemoteLinksStep","description":"This step updates remote links between two records of linked data models.\n\nLearn more in the [Remote Link documentation.](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#create-link).","link":"../../../Steps_Common/functions/core_flows.Common.Steps_Common.updateRemoteLinksStep/page.mdx","depth":1},{"type":"step","name":"dismissRemoteLinkStep","description":"This step removes remote links between two records of linked data models.\n\nLearn more in the [Remote Link documentation.](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#dismiss-link).","link":"../../../Steps_Common/functions/core_flows.Common.Steps_Common.dismissRemoteLinkStep/page.mdx","depth":1}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
|
||||
+43
-14
@@ -14,7 +14,12 @@ This documentation provides a reference to the `createLinksWorkflow`. It belongs
|
||||
|
||||
This workflow creates one or more links between records.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/common/workflows/create-links.ts#L13" />
|
||||
You can use this workflow within your customizations or your own custom workflows, allowing you to
|
||||
create links within your custom flows.
|
||||
|
||||
Learn more about links in [this documentation](https://docs.medusajs.com/learn/fundamentals/module-links/link).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/common/workflows/create-links.ts#L38" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -34,9 +39,15 @@ export async function POST(
|
||||
) {
|
||||
const { result } = await createLinksWorkflow(req.scope)
|
||||
.run({
|
||||
input: [
|
||||
{}
|
||||
]
|
||||
input: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_123",
|
||||
},
|
||||
}]
|
||||
})
|
||||
|
||||
res.send(result)
|
||||
@@ -59,9 +70,15 @@ export default async function handleOrderPlaced({
|
||||
}: SubscriberArgs < { id: string } > ) {
|
||||
const { result } = await createLinksWorkflow(container)
|
||||
.run({
|
||||
input: [
|
||||
{}
|
||||
]
|
||||
input: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_123",
|
||||
},
|
||||
}]
|
||||
})
|
||||
|
||||
console.log(result)
|
||||
@@ -84,9 +101,15 @@ export default async function myCustomJob(
|
||||
) {
|
||||
const { result } = await createLinksWorkflow(container)
|
||||
.run({
|
||||
input: [
|
||||
{}
|
||||
]
|
||||
input: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_123",
|
||||
},
|
||||
}]
|
||||
})
|
||||
|
||||
console.log(result)
|
||||
@@ -110,9 +133,15 @@ const myWorkflow = createWorkflow(
|
||||
() => {
|
||||
const result = createLinksWorkflow
|
||||
.runAsStep({
|
||||
input: [
|
||||
{}
|
||||
]
|
||||
input: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_123",
|
||||
},
|
||||
}]
|
||||
})
|
||||
}
|
||||
)
|
||||
@@ -123,7 +152,7 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"createLinksWorkflow","steps":[{"type":"step","name":"createRemoteLinkStep","description":"This step creates remote links between two records of linked data models.\n\nLearn more in the [Remote Link documentation.](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#create-link).\n\n","link":"../../../Steps_Common/functions/core_flows.Common.Steps_Common.createRemoteLinkStep/page.mdx","depth":1}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"createLinksWorkflow","steps":[{"type":"step","name":"createRemoteLinkStep","description":"This step creates remote links between two records of linked data models.\n\nLearn more in the [Remote Link documentation.](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#create-link).","link":"../../../Steps_Common/functions/core_flows.Common.Steps_Common.createRemoteLinkStep/page.mdx","depth":1}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
|
||||
+43
-14
@@ -14,7 +14,12 @@ This documentation provides a reference to the `dismissLinksWorkflow`. It belong
|
||||
|
||||
This workflow dismisses one or more links between records.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/common/workflows/dismiss-links.ts#L13" />
|
||||
You can use this workflow within your customizations or your own custom workflows, allowing you to
|
||||
dismiss links within your custom flows.
|
||||
|
||||
Learn more about links in [this documentation](https://docs.medusajs.com/learn/fundamentals/module-links/link).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/common/workflows/dismiss-links.ts#L38" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -34,9 +39,15 @@ export async function POST(
|
||||
) {
|
||||
const { result } = await dismissLinksWorkflow(req.scope)
|
||||
.run({
|
||||
input: [
|
||||
{}
|
||||
]
|
||||
input: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_123",
|
||||
},
|
||||
}]
|
||||
})
|
||||
|
||||
res.send(result)
|
||||
@@ -59,9 +70,15 @@ export default async function handleOrderPlaced({
|
||||
}: SubscriberArgs < { id: string } > ) {
|
||||
const { result } = await dismissLinksWorkflow(container)
|
||||
.run({
|
||||
input: [
|
||||
{}
|
||||
]
|
||||
input: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_123",
|
||||
},
|
||||
}]
|
||||
})
|
||||
|
||||
console.log(result)
|
||||
@@ -84,9 +101,15 @@ export default async function myCustomJob(
|
||||
) {
|
||||
const { result } = await dismissLinksWorkflow(container)
|
||||
.run({
|
||||
input: [
|
||||
{}
|
||||
]
|
||||
input: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_123",
|
||||
},
|
||||
}]
|
||||
})
|
||||
|
||||
console.log(result)
|
||||
@@ -110,9 +133,15 @@ const myWorkflow = createWorkflow(
|
||||
() => {
|
||||
const result = dismissLinksWorkflow
|
||||
.runAsStep({
|
||||
input: [
|
||||
{}
|
||||
]
|
||||
input: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_123",
|
||||
},
|
||||
}]
|
||||
})
|
||||
}
|
||||
)
|
||||
@@ -123,7 +152,7 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"dismissLinksWorkflow","steps":[{"type":"step","name":"dismissRemoteLinkStep","description":"This step removes remote links between two records of linked data models.\n\nLearn more in the [Remote Link documentation.](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#dismiss-link).\n\n","link":"../../../Steps_Common/functions/core_flows.Common.Steps_Common.dismissRemoteLinkStep/page.mdx","depth":1}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"dismissLinksWorkflow","steps":[{"type":"step","name":"dismissRemoteLinkStep","description":"This step removes remote links between two records of linked data models.\n\nLearn more in the [Remote Link documentation.](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#dismiss-link).","link":"../../../Steps_Common/functions/core_flows.Common.Steps_Common.dismissRemoteLinkStep/page.mdx","depth":1}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
|
||||
+63
-14
@@ -14,7 +14,12 @@ This documentation provides a reference to the `updateLinksWorkflow`. It belongs
|
||||
|
||||
This workflow updates one or more links between records.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/common/workflows/update-links.ts#L13" />
|
||||
You can use this workflow within your customizations or your own custom workflows, allowing you to
|
||||
update links within your custom flows.
|
||||
|
||||
Learn more about links in [this documentation](https://docs.medusajs.com/learn/fundamentals/module-links/link).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/common/workflows/update-links.ts#L43" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -34,9 +39,20 @@ export async function POST(
|
||||
) {
|
||||
const { result } = await updateLinksWorkflow(req.scope)
|
||||
.run({
|
||||
input: [
|
||||
{}
|
||||
]
|
||||
input: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_123",
|
||||
},
|
||||
data: {
|
||||
metadata: {
|
||||
test: false,
|
||||
},
|
||||
}
|
||||
}]
|
||||
})
|
||||
|
||||
res.send(result)
|
||||
@@ -59,9 +75,20 @@ export default async function handleOrderPlaced({
|
||||
}: SubscriberArgs < { id: string } > ) {
|
||||
const { result } = await updateLinksWorkflow(container)
|
||||
.run({
|
||||
input: [
|
||||
{}
|
||||
]
|
||||
input: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_123",
|
||||
},
|
||||
data: {
|
||||
metadata: {
|
||||
test: false,
|
||||
},
|
||||
}
|
||||
}]
|
||||
})
|
||||
|
||||
console.log(result)
|
||||
@@ -84,9 +111,20 @@ export default async function myCustomJob(
|
||||
) {
|
||||
const { result } = await updateLinksWorkflow(container)
|
||||
.run({
|
||||
input: [
|
||||
{}
|
||||
]
|
||||
input: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_123",
|
||||
},
|
||||
data: {
|
||||
metadata: {
|
||||
test: false,
|
||||
},
|
||||
}
|
||||
}]
|
||||
})
|
||||
|
||||
console.log(result)
|
||||
@@ -110,9 +148,20 @@ const myWorkflow = createWorkflow(
|
||||
() => {
|
||||
const result = updateLinksWorkflow
|
||||
.runAsStep({
|
||||
input: [
|
||||
{}
|
||||
]
|
||||
input: [{
|
||||
// import { Modules } from "@medusajs/framework/utils"
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
"helloModuleService": {
|
||||
my_custom_id: "mc_123",
|
||||
},
|
||||
data: {
|
||||
metadata: {
|
||||
test: false,
|
||||
},
|
||||
}
|
||||
}]
|
||||
})
|
||||
}
|
||||
)
|
||||
@@ -123,7 +172,7 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"updateLinksWorkflow","steps":[{"type":"step","name":"updateRemoteLinksStep","description":"\n\n","link":"../../../Steps_Common/functions/core_flows.Common.Steps_Common.updateRemoteLinksStep/page.mdx","depth":1}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"updateLinksWorkflow","steps":[{"type":"step","name":"updateRemoteLinksStep","description":"This step updates remote links between two records of linked data models.\n\nLearn more in the [Remote Link documentation.](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#create-link).","link":"../../../Steps_Common/functions/core_flows.Common.Steps_Common.updateRemoteLinksStep/page.mdx","depth":1}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
|
||||
+14
-12
@@ -14,24 +14,26 @@ This documentation provides a reference to the `createCustomerAddressesStep`. It
|
||||
|
||||
This step creates one or more customer addresses.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { createCustomerAddressesStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = createCustomerAddressesStep([{
|
||||
"customer_id": "{value}"
|
||||
}])
|
||||
```ts
|
||||
const data = createCustomerAddressesStep([
|
||||
{
|
||||
customer_id: "cus_123",
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
address_1: "123 Main St",
|
||||
city: "Anytown",
|
||||
province: "NY",
|
||||
postal_code: "12345",
|
||||
country_code: "us",
|
||||
}
|
||||
)
|
||||
])
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"CreateCustomerAddressDTO[]","type":"[CreateCustomerAddressDTO](../../../../../customer/interfaces/customer.CreateCustomerAddressDTO/page.mdx)[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"CreateCustomerAddressDTO","type":"[CreateCustomerAddressDTO](../../../../../customer/interfaces/customer.CreateCustomerAddressDTO/page.mdx)","optional":false,"defaultValue":"","description":"The customer address to be created.","expandable":false,"children":[{"name":"customer_id","type":"`string`","description":"The associated customer's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"The address's name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"Whether the address is default shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"Whether the address is the default for billing.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"The company.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`null` \\| `string`","description":"The address 1.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`null` \\| `string`","description":"The address 2.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`null` \\| `string`","description":"The city.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`null` \\| `string`","description":"The country code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`null` \\| `string`","description":"The province.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`null` \\| `string`","description":"The postal code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createCustomerAddressesStep"/>
|
||||
<TypeList types={[{"name":"CreateCustomerAddressesStepInput","type":"[CreateCustomerAddressesStepInput](../../../../types/core_flows.CreateCustomerAddressesStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"customer_id","type":"`string`","description":"The associated customer's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"The address's name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"Whether the address is default shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"Whether the address is the default for billing.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"The company.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`null` \\| `string`","description":"The address 1.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`null` \\| `string`","description":"The address 2.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`null` \\| `string`","description":"The city.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`null` \\| `string`","description":"The country code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`null` \\| `string`","description":"The province.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`null` \\| `string`","description":"The postal code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createCustomerAddressesStep"/>
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+9
-12
@@ -14,24 +14,21 @@ This documentation provides a reference to the `createCustomersStep`. It belongs
|
||||
|
||||
This step creates one or more customers.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { createCustomersStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = createCustomersStep([
|
||||
{}
|
||||
])
|
||||
```ts
|
||||
const data = createCustomersStep([
|
||||
{
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
email: "customer@example.com",
|
||||
}
|
||||
)
|
||||
])
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"CreateCustomerDTO[]","type":"[CreateCustomerDTO](../../../../../customer/interfaces/customer.CreateCustomerDTO/page.mdx)[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"CreateCustomerDTO","type":"[CreateCustomerDTO](../../../../../customer/interfaces/customer.CreateCustomerDTO/page.mdx)","optional":false,"defaultValue":"","description":"The customer to be created.","expandable":false,"children":[{"name":"company_name","type":"`null` \\| `string`","description":"The company name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"The email of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"Who created the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"Whether the customer has an account.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"addresses","type":"Omit<[CreateCustomerAddressDTO](../../../../../customer/interfaces/customer.CreateCustomerAddressDTO/page.mdx), \"customer_id\">[]","description":"The addresses of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"address_name","type":"`null` \\| `string`","description":"The address's name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"Whether the address is default shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"Whether the address is the default for billing.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"The company.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`null` \\| `string`","description":"The address 1.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`null` \\| `string`","description":"The address 2.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`null` \\| `string`","description":"The city.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`null` \\| `string`","description":"The country code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`null` \\| `string`","description":"The province.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`null` \\| `string`","description":"The postal code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createCustomersStep"/>
|
||||
<TypeList types={[{"name":"CreateCustomersStepInput","type":"[CreateCustomersStepInput](../../../../types/core_flows.CreateCustomersStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"company_name","type":"`null` \\| `string`","description":"The company name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"The email of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"Who created the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"Whether the customer has an account.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"addresses","type":"Omit<[CreateCustomerAddressDTO](../../../../../customer/interfaces/customer.CreateCustomerAddressDTO/page.mdx), \"customer_id\">[]","description":"The addresses of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"address_name","type":"`null` \\| `string`","description":"The address's name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"Whether the address is default shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"Whether the address is the default for billing.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"The company.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`null` \\| `string`","description":"The address 1.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`null` \\| `string`","description":"The address 2.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`null` \\| `string`","description":"The city.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`null` \\| `string`","description":"The country code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`null` \\| `string`","description":"The province.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`null` \\| `string`","description":"The postal code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createCustomersStep"/>
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+2
-4
@@ -21,9 +21,7 @@ import { deleteCustomerAddressesStep } from "@medusajs/medusa/core-flows"
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = deleteCustomerAddressesStep([
|
||||
"{value}"
|
||||
])
|
||||
const data = deleteCustomerAddressesStep({})
|
||||
}
|
||||
)
|
||||
```
|
||||
@@ -31,4 +29,4 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"string[]","type":"`string`[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"string","type":"`string`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="deleteCustomerAddressesStep"/>
|
||||
<TypeList types={[{"name":"DeleteCustomerAddressesStepInput","type":"[DeleteCustomerAddressesStepInput](../../../../types/core_flows.DeleteCustomerAddressesStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"DeleteCustomerAddressesStepInput","type":"`string`[]","description":"The IDs of the customer addresses to delete.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="deleteCustomerAddressesStep"/>
|
||||
+2
-4
@@ -21,9 +21,7 @@ import { deleteCustomersStep } from "@medusajs/medusa/core-flows"
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = deleteCustomersStep([
|
||||
"{value}"
|
||||
])
|
||||
const data = deleteCustomersStep({})
|
||||
}
|
||||
)
|
||||
```
|
||||
@@ -31,4 +29,4 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"string[]","type":"`string`[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"string","type":"`string`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="deleteCustomersStep"/>
|
||||
<TypeList types={[{"name":"DeleteCustomersStepInput","type":"[DeleteCustomersStepInput](../../../../types/core_flows.DeleteCustomersStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"DeleteCustomersStepInput","type":"`string`[]","description":"The IDs of the customers to delete.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="deleteCustomersStep"/>
|
||||
+25
-11
@@ -12,21 +12,35 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `maybeUnsetDefaultBillingAddressesStep`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This step unsets the `is_default_billing` property of one or more addresses.
|
||||
This step unsets the `is_default_billing` property of existing customer addresses
|
||||
if the `is_default_billing` property in the addresses in the input is set to `true`.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { maybeUnsetDefaultBillingAddressesStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = maybeUnsetDefaultBillingAddressesStep({})
|
||||
```ts
|
||||
const data = maybeUnsetDefaultBillingAddressesStep({
|
||||
create: [{
|
||||
customer_id: "cus_123",
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
address_1: "123 Main St",
|
||||
city: "Anytown",
|
||||
country_code: "US",
|
||||
postal_code: "12345",
|
||||
phone: "555-555-5555"
|
||||
is_default_billing: true
|
||||
}],
|
||||
update: {
|
||||
selector: {
|
||||
customer_id: "cus_123"
|
||||
},
|
||||
update: {
|
||||
is_default_billing: true
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"MaybeUnsetDefaultBillingAddressStepInput","type":"[MaybeUnsetDefaultBillingAddressStepInput](../../../../types/core_flows.MaybeUnsetDefaultBillingAddressStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"create","type":"[CreateCustomerAddressDTO](../../../../../customer/interfaces/customer.CreateCustomerAddressDTO/page.mdx)[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"customer_id","type":"`string`","description":"The associated customer's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"The address's name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"Whether the address is default shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"Whether the address is the default for billing.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"The company.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`null` \\| `string`","description":"The address 1.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`null` \\| `string`","description":"The address 2.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`null` \\| `string`","description":"The city.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`null` \\| `string`","description":"The country code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`null` \\| `string`","description":"The province.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`null` \\| `string`","description":"The postal code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"update","type":"`object`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"selector","type":"[FilterableCustomerAddressProps](../../../../../customer/interfaces/customer.FilterableCustomerAddressProps/page.mdx)","description":"The filters to apply on the retrieved customer address.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Searches for addresses by properties such as name and street using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"The IDs to filter the customer address by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`string` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<string>","description":"Filter addresses by name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<boolean>","description":"Filter addresses by whether they're the default for shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<boolean>","description":"Filter addresses by whether they're the default for billing.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"`string` \\| `string`[]","description":"Filter addresses by the associated customer's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer","type":"`string` \\| `string`[] \\| [FilterableCustomerProps](../../../../../customer/interfaces/customer.FilterableCustomerProps/page.mdx)","description":"Filter addresses by the associated customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`string` \\| [OperatorMap](../../.Line truncated
|
||||
<TypeList types={[{"name":"MaybeUnsetDefaultBillingAddressStepInput","type":"[MaybeUnsetDefaultBillingAddressStepInput](../../../../types/core_flows.MaybeUnsetDefaultBillingAddressStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"create","type":"[CreateCustomerAddressDTO](../../../../../customer/interfaces/customer.CreateCustomerAddressDTO/page.mdx)[]","description":"The addresses being created. If the address has \nthe `is_default_billing` property set to `true`,\nthe existing default billing address of the customer will be unset.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"customer_id","type":"`string`","description":"The associated customer's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"The address's name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"Whether the address is default shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"Whether the address is the default for billing.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"The company.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`null` \\| `string`","description":"The address 1.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`null` \\| `string`","description":"The address 2.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`null` \\| `string`","description":"The city.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`null` \\| `string`","description":"The country code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`null` \\| `string`","description":"The province.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`null` \\| `string`","description":"The postal code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"update","type":"`object`","description":"The addresses being updated.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"selector","type":"[FilterableCustomerAddressProps](../../../../../customer/interfaces/customer.FilterableCustomerAddressProps/page.mdx)","description":"The selector to identify the customers to unset their default billing address.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Searches for addresses by properties such as name and street using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"The IDs to filter the customer address by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`string` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<string>","description":"Filter addresses by name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<boolean>","description":"Filter addresses by whether they're the default for shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<boolean>","description":"Filter addresses by whether they're the default for billing.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"`string` \\| `string`[]","description":"Filter addresses by the associated customer's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer","type":"`string` \\| `string`[] \\| [FilterableCustomerProps](../../../../../customer/interfaces/customer.FilterLine truncated
|
||||
+25
-11
@@ -12,21 +12,35 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `maybeUnsetDefaultShippingAddressesStep`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This step unsets the `is_default_shipping` property of one or more addresses.
|
||||
This step unsets the `is_default_billing` property of existing customer addresses
|
||||
if the `is_default_billing` property in the addresses in the input is set to `true`.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { maybeUnsetDefaultShippingAddressesStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = maybeUnsetDefaultShippingAddressesStep({})
|
||||
```ts
|
||||
const data = maybeUnsetDefaultShippingAddressesStep({
|
||||
create: [{
|
||||
customer_id: "cus_123",
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
address_1: "123 Main St",
|
||||
city: "Anytown",
|
||||
country_code: "US",
|
||||
postal_code: "12345",
|
||||
phone: "555-555-5555",
|
||||
is_default_shipping: true
|
||||
}],
|
||||
update: {
|
||||
selector: {
|
||||
customer_id: "cus_123"
|
||||
},
|
||||
update: {
|
||||
is_default_shipping: true
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"MaybeUnsetDefaultShippingAddressesStepInput","type":"[MaybeUnsetDefaultShippingAddressesStepInput](../../../../types/core_flows.MaybeUnsetDefaultShippingAddressesStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"create","type":"[CreateCustomerAddressDTO](../../../../../customer/interfaces/customer.CreateCustomerAddressDTO/page.mdx)[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"customer_id","type":"`string`","description":"The associated customer's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"The address's name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"Whether the address is default shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"Whether the address is the default for billing.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"The company.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`null` \\| `string`","description":"The address 1.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`null` \\| `string`","description":"The address 2.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`null` \\| `string`","description":"The city.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`null` \\| `string`","description":"The country code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`null` \\| `string`","description":"The province.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`null` \\| `string`","description":"The postal code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"update","type":"`object`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"selector","type":"[FilterableCustomerAddressProps](../../../../../customer/interfaces/customer.FilterableCustomerAddressProps/page.mdx)","description":"The filters to apply on the retrieved customer address.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Searches for addresses by properties such as name and street using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"The IDs to filter the customer address by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`string` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<string>","description":"Filter addresses by name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<boolean>","description":"Filter addresses by whether they're the default for shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<boolean>","description":"Filter addresses by whether they're the default for billing.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"`string` \\| `string`[]","description":"Filter addresses by the associated customer's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer","type":"`string` \\| `string`[] \\| [FilterableCustomerProps](../../../../../customer/interfaces/customer.FilterableCustomerProps/page.mdx)","description":"Filter addresses by the associated customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`string` \\| [OperatorMapLine truncated
|
||||
<TypeList types={[{"name":"MaybeUnsetDefaultShippingAddressesStepInput","type":"[MaybeUnsetDefaultShippingAddressesStepInput](../../../../types/core_flows.MaybeUnsetDefaultShippingAddressesStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"create","type":"[CreateCustomerAddressDTO](../../../../../customer/interfaces/customer.CreateCustomerAddressDTO/page.mdx)[]","description":"The addresses being created. If the address has\nthe `is_default_shipping` property set to `true`,\nthe existing default shipping address of the customer will be unset.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"customer_id","type":"`string`","description":"The associated customer's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"The address's name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"Whether the address is default shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"Whether the address is the default for billing.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"The company.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`null` \\| `string`","description":"The address 1.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`null` \\| `string`","description":"The address 2.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`null` \\| `string`","description":"The city.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`null` \\| `string`","description":"The country code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`null` \\| `string`","description":"The province.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`null` \\| `string`","description":"The postal code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"update","type":"`object`","description":"The addresses being updated.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"selector","type":"[FilterableCustomerAddressProps](../../../../../customer/interfaces/customer.FilterableCustomerAddressProps/page.mdx)","description":"The selector to identify the customers to unset their default shipping address.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Searches for addresses by properties such as name and street using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"The IDs to filter the customer address by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`string` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<string>","description":"Filter addresses by name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<boolean>","description":"Filter addresses by whether they're the default for shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<boolean>","description":"Filter addresses by whether they're the default for billing.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"`string` \\| `string`[]","description":"Filter addresses by the associated customer's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer","type":"`string` \\| `string`[] \\| [FilterableCustomerProps](../../../../../customer/interfaces/custLine truncated
|
||||
+10
-13
@@ -14,25 +14,22 @@ This documentation provides a reference to the `updateCustomerAddressesStep`. It
|
||||
|
||||
This step updates one or more customer addresses.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { updateCustomerAddressesStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = updateCustomerAddressesStep({
|
||||
"selector": {},
|
||||
"update": {}
|
||||
})
|
||||
```ts
|
||||
const data = updateCustomerAddressesStep({
|
||||
selector: {
|
||||
customer_id: "cus_123"
|
||||
},
|
||||
update: {
|
||||
country_code: "us"
|
||||
}
|
||||
)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"UpdateCustomerAddresseStepInput","type":"[UpdateCustomerAddresseStepInput](../../../../types/core_flows.UpdateCustomerAddresseStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"selector","type":"[FilterableCustomerAddressProps](../../../../../customer/interfaces/customer.FilterableCustomerAddressProps/page.mdx)","description":"The filters to apply on the retrieved customer address.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Searches for addresses by properties such as name and street using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"The IDs to filter the customer address by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`string` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<string>","description":"Filter addresses by name.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"$and","type":"[Query](../../../../../customer/types/customer.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$or","type":"[Query](../../../../../customer/types/customer.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$eq","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T> \\| [ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ne","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$in","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$nin","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$not","type":"[Query](../../../../../customer/types/customer.Query/page.mdx)<T>","description":"API wrapper around the remoteQuery","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gt","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gte","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lt","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lte","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$like","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$re","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ilike","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$fulltext","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$overlap","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contains","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contained","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$exists","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"is_default_shipping","type":"`boolean` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<boolean>","description":"Filter addresses by whether they're the default for shipping.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"$and","type":"[Query](../../../../../customer/types/customer.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$or","type":"[Query](../../../../../customer/types/customer.Query/page.mdx)<T>[]","description":"","optional":true,"defaLine truncated
|
||||
<TypeList types={[{"name":"UpdateCustomerAddresseStepInput","type":"[UpdateCustomerAddresseStepInput](../../../../types/core_flows.UpdateCustomerAddresseStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"selector","type":"[FilterableCustomerAddressProps](../../../../../customer/interfaces/customer.FilterableCustomerAddressProps/page.mdx)","description":"The filters to select the customer addresses to update.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Searches for addresses by properties such as name and street using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"The IDs to filter the customer address by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`string` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<string>","description":"Filter addresses by name.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"$and","type":"[Query](../../../../../customer/types/customer.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$or","type":"[Query](../../../../../customer/types/customer.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$eq","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T> \\| [ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ne","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$in","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$nin","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$not","type":"[Query](../../../../../customer/types/customer.Query/page.mdx)<T>","description":"API wrapper around the remoteQuery","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gt","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gte","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lt","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lte","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$like","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$re","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ilike","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$fulltext","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$overlap","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contains","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contained","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$exists","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"is_default_shipping","type":"`boolean` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<boolean>","description":"Filter addresses by whether they're the default for shipping.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"$and","type":"[Query](../../../../../customer/types/customer.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$or","type":"[Query](../../../../../customer/types/customer.Query/page.mdx)<T>[]","description":"","optional":true,"defaLine truncated
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+10
-13
@@ -14,25 +14,22 @@ This documentation provides a reference to the `updateCustomersStep`. It belongs
|
||||
|
||||
This step updates one or more customers.
|
||||
|
||||
```ts title="src/workflows/my-workflow.ts"
|
||||
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
|
||||
import { updateCustomersStep } from "@medusajs/medusa/core-flows"
|
||||
## Example
|
||||
|
||||
const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
() => {
|
||||
const data = updateCustomersStep({
|
||||
"selector": {},
|
||||
"update": {}
|
||||
})
|
||||
```ts
|
||||
const data = updateCustomersStep({
|
||||
selector: {
|
||||
id: "cus_123"
|
||||
},
|
||||
update: {
|
||||
last_name: "Doe"
|
||||
}
|
||||
)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"UpdateCustomersStepInput","type":"[UpdateCustomersStepInput](../../../../types/core_flows.UpdateCustomersStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"selector","type":"[FilterableCustomerProps](../../../../../customer/interfaces/customer.FilterableCustomerProps/page.mdx)","description":"The filters to apply on the retrieved customer.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Searches for customers by properties such as name and email using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"The IDs to filter the customer by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string` \\| `string`[] \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<string>","description":"Filter by email.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"$and","type":"[Query](../../../../../customer/types/customer.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$or","type":"[Query](../../../../../customer/types/customer.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$eq","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T> \\| [ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ne","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$in","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$nin","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$not","type":"[Query](../../../../../customer/types/customer.Query/page.mdx)<T>","description":"API wrapper around the remoteQuery","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gt","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gte","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lt","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lte","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$like","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$re","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ilike","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$fulltext","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$overlap","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contains","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contained","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$exists","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"groups","type":"`string` \\| `string`[] \\| [FilterableCustomerGroupProps](../../../../../customer/interfaces/customer.FilterableCustomerGroupProps/page.mdx)","description":"Filter by associated customer group.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Searches for customer groups by name using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"The IDs to filter the customer group by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`Line truncated
|
||||
<TypeList types={[{"name":"UpdateCustomersStepInput","type":"[UpdateCustomersStepInput](../../../../types/core_flows.UpdateCustomersStepInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"selector","type":"[FilterableCustomerProps](../../../../../customer/interfaces/customer.FilterableCustomerProps/page.mdx)","description":"The filters to select the customers to update.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Searches for customers by properties such as name and email using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"The IDs to filter the customer by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string` \\| `string`[] \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<string>","description":"Filter by email.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"$and","type":"[Query](../../../../../customer/types/customer.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$or","type":"[Query](../../../../../customer/types/customer.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$eq","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T> \\| [ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ne","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$in","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$nin","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$not","type":"[Query](../../../../../customer/types/customer.Query/page.mdx)<T>","description":"API wrapper around the remoteQuery","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gt","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gte","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lt","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lte","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$like","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$re","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ilike","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$fulltext","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$overlap","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contains","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contained","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$exists","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"groups","type":"`string` \\| `string`[] \\| [FilterableCustomerGroupProps](../../../../../customer/interfaces/customer.FilterableCustomerGroupProps/page.mdx)","description":"Filter by associated customer group.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Searches for customer groups by name using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"The IDs to filter the customer group by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string` Line truncated
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
---
|
||||
slug: /references/medusa-workflows/steps/validateCustomerAccountCreation
|
||||
sidebar_label: validateCustomerAccountCreation
|
||||
tags:
|
||||
- customer
|
||||
- step
|
||||
---
|
||||
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
# validateCustomerAccountCreation - Medusa Core Workflows Reference
|
||||
|
||||
This documentation provides a reference to the `validateCustomerAccountCreation`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This step validates the input data for creating a customer account.
|
||||
The step throws an error if:
|
||||
|
||||
- The email is missing
|
||||
- A customer with the email already exists and has an account
|
||||
- A guest customer with the email already exists
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
const data = validateCustomerAccountCreation({
|
||||
authIdentityId: "au_1234",
|
||||
customerData: {
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
email: "john.doe@example.com",
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"CreateCustomerAccountWorkflowInput","type":"[CreateCustomerAccountWorkflowInput](../../../../types/core_flows.CreateCustomerAccountWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"authIdentityId","type":"`string`","description":"The ID of the auth identity to attach the customer to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customerData","type":"[CreateCustomerDTO](../../../../../customer/interfaces/customer.CreateCustomerDTO/page.mdx)","description":"The details of the customer to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"company_name","type":"`null` \\| `string`","description":"The company name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"The email of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"Who created the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"Whether the customer has an account.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"addresses","type":"Omit<[CreateCustomerAddressDTO](../../../../../customer/interfaces/customer.CreateCustomerAddressDTO/page.mdx), \"customer_id\">[]","description":"The addresses of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"address_name","type":"`null` \\| `string`","description":"The address's name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"Whether the address is default shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"Whether the address is the default for billing.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"The company.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`null` \\| `string`","description":"The address 1.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`null` \\| `string`","description":"The address 2.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`null` \\| `string`","description":"The city.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`null` \\| `string`","description":"The country code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`null` \\| `string`","description":"The province.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`null` \\| `string`","description":"The postal code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validateCustomerAccountCreation"/>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
# validateCustomerAccountCreationStepId
|
||||
|
||||
`Const` **validateCustomerAccountCreationStepId**: `"validate-customer-account-creation"`
|
||||
+36
-13
@@ -2,9 +2,9 @@
|
||||
slug: /references/medusa-workflows/createCustomerAccountWorkflow
|
||||
sidebar_label: createCustomerAccountWorkflow
|
||||
tags:
|
||||
- customer
|
||||
- auth
|
||||
- workflow
|
||||
- customer
|
||||
- event bus
|
||||
---
|
||||
|
||||
@@ -14,9 +14,16 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `createCustomerAccountWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow creates an authentication account for a customer.
|
||||
This workflow creates a customer and attaches it to an auth identity. It's used by the
|
||||
[Register Customer Store API Route](https://docs.medusajs.com/api/store#customers\_postcustomers).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/customer/workflows/create-customer-account.ts#L21" />
|
||||
You can create an auth identity first using the [Retrieve Registration JWT Token API Route](https://docs.medusajs.com/api/store#auth\_postactor\_typeauth\_provider\_register).
|
||||
Learn more about basic authentication flows in [this documentation](https://docs.medusajs.com/resources/commerce-modules/auth/authentication-route).
|
||||
|
||||
You can use this workflow within your customizations or your own custom workflows, allowing you to
|
||||
register or create customer accounts within your custom flows.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/customer/workflows/create-customer-account.ts#L54" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -37,8 +44,12 @@ export async function POST(
|
||||
const { result } = await createCustomerAccountWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"authIdentityId": "{value}",
|
||||
"customerData": {}
|
||||
authIdentityId: "au_1234",
|
||||
customerData: {
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
email: "john.doe@example.com",
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -63,8 +74,12 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await createCustomerAccountWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"authIdentityId": "{value}",
|
||||
"customerData": {}
|
||||
authIdentityId: "au_1234",
|
||||
customerData: {
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
email: "john.doe@example.com",
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -89,8 +104,12 @@ export default async function myCustomJob(
|
||||
const { result } = await createCustomerAccountWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"authIdentityId": "{value}",
|
||||
"customerData": {}
|
||||
authIdentityId: "au_1234",
|
||||
customerData: {
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
email: "john.doe@example.com",
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -116,8 +135,12 @@ const myWorkflow = createWorkflow(
|
||||
const result = createCustomerAccountWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"authIdentityId": "{value}",
|
||||
"customerData": {}
|
||||
authIdentityId: "au_1234",
|
||||
customerData: {
|
||||
first_name: "John",
|
||||
last_name: "Doe",
|
||||
email: "john.doe@example.com",
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -129,11 +152,11 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"createCustomerAccountWorkflow","steps":[{"type":"workflow","name":"createCustomersWorkflow","description":"This workflow creates one or more customers. It's used by the [Create Customer Admin API Route](https://docs.medusajs.com/api/admin#customers\\_postcustomers).\n\nThis workflow has a hook that allows you to perform custom actions on the created customer. You can see an example in [this guide](https://docs.medusajs.com/resources/commerce-modules/customer/extend).\n\nYou can also use this workflow within your own custom workflows, allowing you to wrap custom logic around creating customers.\n\n","link":"../core_flows.Customer.Workflows_Customer.createCustomersWorkflow/page.mdx","depth":1},{"type":"step","name":"setAuthAppMetadataStep","description":"This step sets the `app_metadata` property of an auth identity.\n\n","link":"../../../../Auth/Steps_Auth/functions/core_flows.Auth.Steps_Auth.setAuthAppMetadataStep/page.mdx","depth":2}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"createCustomerAccountWorkflow","steps":[{"type":"step","name":"validateCustomerAccountCreation","description":"This step validates the input data for creating a customer account.\nThe step throws an error if:\n\n- The email is missing\n- A customer with the email already exists and has an account\n- A guest customer with the email already exists","link":"../../../Steps_Customer/functions/core_flows.Customer.Steps_Customer.validateCustomerAccountCreation/page.mdx","depth":1},{"type":"workflow","name":"createCustomersWorkflow","description":"This workflow creates one or more customers. It's used by the [Create Customer Admin API Route](https://docs.medusajs.com/api/admin#customers\\_postcustomers).\n\nThis workflow has a hook that allows you to perform custom actions on the created customer. You can see an example in [this guide](https://docs.medusajs.com/resources/commerce-modules/customer/extend).\n\nYou can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around creating customers.","link":"../core_flows.Customer.Workflows_Customer.createCustomersWorkflow/page.mdx","depth":2},{"type":"step","name":"setAuthAppMetadataStep","description":"This step sets the `app_metadata` property of an auth identity. This is useful to\nassociate a user (whether it's an admin user or customer) with an auth identity\nthat allows them to authenticate into Medusa.\n\nYou can learn more about auth identites in \n[this documentation](https://docs.medusajs.com/resources/commerce-modules/auth/auth-identity-and-actor-types).\n\nTo use this for a custom actor type, check out [this guide](https://docs.medusajs.com/resources/commerce-modules/auth/create-actor-type)\nthat explains how to create a custom `manager` actor type and manage its users.","link":"../../../../Auth/Steps_Auth/functions/core_flows.Auth.Steps_Auth.setAuthAppMetadataStep/page.mdx","depth":3}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"CreateCustomerAccountWorkflowInput","type":"[CreateCustomerAccountWorkflowInput](../../../../types/core_flows.CreateCustomerAccountWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"authIdentityId","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customerData","type":"[CreateCustomerDTO](../../../../../customer/interfaces/customer.CreateCustomerDTO/page.mdx)","description":"The customer to be created.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"company_name","type":"`null` \\| `string`","description":"The company name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"The email of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"Who created the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"Whether the customer has an account.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"addresses","type":"Omit<[CreateCustomerAddressDTO](../../../../../customer/interfaces/customer.CreateCustomerAddressDTO/page.mdx), \"customer_id\">[]","description":"The addresses of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"address_name","type":"`null` \\| `string`","description":"The address's name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"Whether the address is default shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"Whether the address is the default for billing.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"The company.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`null` \\| `string`","description":"The address 1.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`null` \\| `string`","description":"The address 2.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`null` \\| `string`","description":"The city.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`null` \\| `string`","description":"The country code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`null` \\| `string`","description":"The province.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`null` \\| `string`","description":"The postal code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createCustomerAccountWorkflow"/>
|
||||
<TypeList types={[{"name":"CreateCustomerAccountWorkflowInput","type":"[CreateCustomerAccountWorkflowInput](../../../../types/core_flows.CreateCustomerAccountWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"The details of the customer account to create.","expandable":false,"children":[{"name":"authIdentityId","type":"`string`","description":"The ID of the auth identity to attach the customer to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customerData","type":"[CreateCustomerDTO](../../../../../customer/interfaces/customer.CreateCustomerDTO/page.mdx)","description":"The details of the customer to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"company_name","type":"`null` \\| `string`","description":"The company name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"The email of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"Who created the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"Whether the customer has an account.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"addresses","type":"Omit<[CreateCustomerAddressDTO](../../../../../customer/interfaces/customer.CreateCustomerAddressDTO/page.mdx), \"customer_id\">[]","description":"The addresses of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"address_name","type":"`null` \\| `string`","description":"The address's name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"Whether the address is default shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"Whether the address is the default for billing.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"The company.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`null` \\| `string`","description":"The address 1.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`null` \\| `string`","description":"The address 2.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`null` \\| `string`","description":"The city.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`null` \\| `string`","description":"The country code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`null` \\| `string`","description":"The province.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`null` \\| `string`","description":"The postal code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createCustomerAccountWorkflow"/>
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+4
-4
@@ -18,9 +18,9 @@ and the [Add Customer Address Store API Route](https://docs.medusajs.com/api/sto
|
||||
This workflow has a hook that allows you to perform custom actions on the created customer addresses. For example, you can pass under `additional_data` custom data that
|
||||
allows you to create custom data models linked to the addresses.
|
||||
|
||||
You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around creating customer addresses.
|
||||
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around creating customer addresses.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/customer/workflows/create-addresses.ts#L74" />
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/customer/workflows/create-addresses.ts#L75" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -213,11 +213,11 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"createCustomerAddressesWorkflow","steps":[{"type":"step","name":"maybeUnsetDefaultShippingAddressesStep","description":"This step unsets the `is_default_shipping` property of one or more addresses.\n\n","link":"../../../Steps_Customer/functions/core_flows.Customer.Steps_Customer.maybeUnsetDefaultShippingAddressesStep/page.mdx","depth":1},{"type":"step","name":"maybeUnsetDefaultBillingAddressesStep","description":"This step unsets the `is_default_billing` property of one or more addresses.\n\n","link":"../../../Steps_Customer/functions/core_flows.Customer.Steps_Customer.maybeUnsetDefaultBillingAddressesStep/page.mdx","depth":1},{"type":"step","name":"createCustomerAddressesStep","description":"This step creates one or more customer addresses.\n\n","link":"../../../Steps_Customer/functions/core_flows.Customer.Steps_Customer.createCustomerAddressesStep/page.mdx","depth":2},{"type":"hook","name":"addressesCreated","description":"This hook is executed after the addresses are created. You can consume this hook to perform custom actions on the created addresses.\n\n","link":"#addressesCreated","depth":3}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"createCustomerAddressesWorkflow","steps":[{"type":"step","name":"maybeUnsetDefaultShippingAddressesStep","description":"This step unsets the `is_default_billing` property of existing customer addresses\nif the `is_default_billing` property in the addresses in the input is set to `true`.","link":"../../../Steps_Customer/functions/core_flows.Customer.Steps_Customer.maybeUnsetDefaultShippingAddressesStep/page.mdx","depth":1},{"type":"step","name":"maybeUnsetDefaultBillingAddressesStep","description":"This step unsets the `is_default_billing` property of existing customer addresses\nif the `is_default_billing` property in the addresses in the input is set to `true`.","link":"../../../Steps_Customer/functions/core_flows.Customer.Steps_Customer.maybeUnsetDefaultBillingAddressesStep/page.mdx","depth":1},{"type":"step","name":"createCustomerAddressesStep","description":"This step creates one or more customer addresses.","link":"../../../Steps_Customer/functions/core_flows.Customer.Steps_Customer.createCustomerAddressesStep/page.mdx","depth":2},{"type":"hook","name":"addressesCreated","description":"This hook is executed after the addresses are created. You can consume this hook to perform custom actions on the created addresses.","link":"#addressesCreated","depth":3}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"object & AdditionalData","type":"`object` & [AdditionalData](../../../../../types/HttpTypes/types/types.HttpTypes.AdditionalData/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"addresses","type":"[CreateCustomerAddressDTO](../../../../../customer/interfaces/customer.CreateCustomerAddressDTO/page.mdx)[]","description":"The addresses to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"customer_id","type":"`string`","description":"The associated customer's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"The address's name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"Whether the address is default shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"Whether the address is the default for billing.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"The company.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`null` \\| `string`","description":"The address 1.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`null` \\| `string`","description":"The address 2.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`null` \\| `string`","description":"The city.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`null` \\| `string`","description":"The country code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`null` \\| `string`","description":"The province.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`null` \\| `string`","description":"The postal code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"AdditionalData","type":"[AdditionalData](../../../../../types/HttpTypes/types/types.HttpTypes.AdditionalData/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"additional_data","type":"`Record<string, unknown>`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\n\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createCustomerAddressesWorkflow"/>
|
||||
<TypeList types={[{"name":"CreateCustomerAddressesWorkflowInput","type":"[CreateCustomerAddressesWorkflowInput](../../../../types/core_flows.CreateCustomerAddressesWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"The data to create one or more customer addresses, along with custom data that's passed to the workflow's hooks.","expandable":false,"children":[{"name":"addresses","type":"[CreateCustomerAddressDTO](../../../../../customer/interfaces/customer.CreateCustomerAddressDTO/page.mdx)[]","description":"The addresses to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"customer_id","type":"`string`","description":"The associated customer's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"The address's name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"Whether the address is default shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"Whether the address is the default for billing.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"The company.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`null` \\| `string`","description":"The address 1.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`null` \\| `string`","description":"The address 2.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`null` \\| `string`","description":"The city.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`null` \\| `string`","description":"The country code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`null` \\| `string`","description":"The province.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`null` \\| `string`","description":"The postal code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown>`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\n\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createCustomerAddressesWorkflow"/>
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+4
-4
@@ -17,9 +17,9 @@ This workflow creates one or more customers. It's used by the [Create Customer A
|
||||
|
||||
This workflow has a hook that allows you to perform custom actions on the created customer. You can see an example in [this guide](https://docs.medusajs.com/resources/commerce-modules/customer/extend).
|
||||
|
||||
You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around creating customers.
|
||||
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around creating customers.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/customer/workflows/create-customers.ts#L53" />
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/customer/workflows/create-customers.ts#L54" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -156,11 +156,11 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"createCustomersWorkflow","steps":[{"type":"step","name":"createCustomersStep","description":"This step creates one or more customers.\n\n","link":"../../../Steps_Customer/functions/core_flows.Customer.Steps_Customer.createCustomersStep/page.mdx","depth":1},{"type":"hook","name":"customersCreated","description":"This hook is executed after the customers are created. You can consume this hook to perform custom actions on the created customers.\n\n","link":"#customersCreated","depth":2},{"type":"step","name":"emitEventStep","description":"Emit an event.\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":3}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"createCustomersWorkflow","steps":[{"type":"step","name":"createCustomersStep","description":"This step creates one or more customers.","link":"../../../Steps_Customer/functions/core_flows.Customer.Steps_Customer.createCustomersStep/page.mdx","depth":1},{"type":"hook","name":"customersCreated","description":"This hook is executed after the customers are created. You can consume this hook to perform custom actions on the created customers.","link":"#customersCreated","depth":2},{"type":"step","name":"emitEventStep","description":"Emit an event.","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":3}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"object & AdditionalData","type":"`object` & [AdditionalData](../../../../../types/HttpTypes/types/types.HttpTypes.AdditionalData/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"customersData","type":"[CreateCustomerDTO](../../../../../customer/interfaces/customer.CreateCustomerDTO/page.mdx)[]","description":"The customers to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"company_name","type":"`null` \\| `string`","description":"The company name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"The email of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"Who created the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"Whether the customer has an account.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"addresses","type":"Omit<[CreateCustomerAddressDTO](../../../../../customer/interfaces/customer.CreateCustomerAddressDTO/page.mdx), \"customer_id\">[]","description":"The addresses of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"AdditionalData","type":"[AdditionalData](../../../../../types/HttpTypes/types/types.HttpTypes.AdditionalData/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"additional_data","type":"`Record<string, unknown>`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\n\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createCustomersWorkflow"/>
|
||||
<TypeList types={[{"name":"CreateCustomersWorkflowInput","type":"[CreateCustomersWorkflowInput](../../../../types/core_flows.CreateCustomersWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"The data to create one or more customers, along with custom data that's passed to the workflow's hooks.","expandable":false,"children":[{"name":"customersData","type":"[CreateCustomerDTO](../../../../../customer/interfaces/customer.CreateCustomerDTO/page.mdx)[]","description":"The customers to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"company_name","type":"`null` \\| `string`","description":"The company name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"The email of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"Who created the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"Whether the customer has an account.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"addresses","type":"Omit<[CreateCustomerAddressDTO](../../../../../customer/interfaces/customer.CreateCustomerAddressDTO/page.mdx), \"customer_id\">[]","description":"The addresses of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"address_name","type":"`null` \\| `string`","description":"The address's name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"Whether the address is default shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"Whether the address is the default for billing.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"The company.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`null` \\| `string`","description":"The address 1.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`null` \\| `string`","description":"The address 2.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`null` \\| `string`","description":"The city.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`null` \\| `string`","description":"The country code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`null` \\| `string`","description":"The province.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`null` \\| `string`","description":"The postal code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"The phone.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"[MetadataType](../../../../../customer/types/customer.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown>`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\n\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createCustomersWorkflow"/>
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
+26
-13
@@ -12,9 +12,22 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `deleteCustomerAddressesWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow deletes one or more customer addresses.
|
||||
This workflow deletes one or more customer addresses. It's used by the
|
||||
[Remove Customer Addresses Admin API Route](https://docs.medusajs.com/api/admin#customers\_deletecustomersidaddressesaddress\_id)
|
||||
and the [Remove Customer Addresses Store API Route](https://docs.medusajs.com/api/store#customers\_deletecustomersmeaddressesaddress\_id).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/customer/workflows/delete-addresses.ts#L15" />
|
||||
:::note
|
||||
|
||||
This workflow deletes addresses created by the [Customer Module](https://docs.medusajs.com/resources/commerce-modules/customer)
|
||||
only. So, you can't delete addresses attached to a cart, for example. To do that, use the workflow
|
||||
relevant to that module.
|
||||
|
||||
:::
|
||||
|
||||
You can use this workflow within your customizations or your own custom workflows, allowing you to
|
||||
delete customer addresses in your custom flows.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/customer/workflows/delete-addresses.ts#L52" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -35,8 +48,8 @@ export async function POST(
|
||||
const { result } = await deleteCustomerAddressesWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"ids": [
|
||||
"id_IRZjwuK6l3RnpPQQ"
|
||||
ids: [
|
||||
"cuaddress_123"
|
||||
]
|
||||
}
|
||||
})
|
||||
@@ -62,8 +75,8 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await deleteCustomerAddressesWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"ids": [
|
||||
"id_IRZjwuK6l3RnpPQQ"
|
||||
ids: [
|
||||
"cuaddress_123"
|
||||
]
|
||||
}
|
||||
})
|
||||
@@ -89,8 +102,8 @@ export default async function myCustomJob(
|
||||
const { result } = await deleteCustomerAddressesWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"ids": [
|
||||
"id_IRZjwuK6l3RnpPQQ"
|
||||
ids: [
|
||||
"cuaddress_123"
|
||||
]
|
||||
}
|
||||
})
|
||||
@@ -117,8 +130,8 @@ const myWorkflow = createWorkflow(
|
||||
const result = deleteCustomerAddressesWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"ids": [
|
||||
"id_IRZjwuK6l3RnpPQQ"
|
||||
ids: [
|
||||
"cuaddress_123"
|
||||
]
|
||||
}
|
||||
})
|
||||
@@ -131,11 +144,11 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"deleteCustomerAddressesWorkflow","steps":[{"type":"step","name":"deleteCustomerAddressesStep","description":"This step deletes one or more customer addresses.\n\n","link":"../../../Steps_Customer/functions/core_flows.Customer.Steps_Customer.deleteCustomerAddressesStep/page.mdx","depth":1},{"type":"hook","name":"addressesDeleted","description":"This step is a hook that you can inject custom functionality into.\n\n","link":"#addressesDeleted","depth":2}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"deleteCustomerAddressesWorkflow","steps":[{"type":"step","name":"deleteCustomerAddressesStep","description":"This step deletes one or more customer addresses.","link":"../../../Steps_Customer/functions/core_flows.Customer.Steps_Customer.deleteCustomerAddressesStep/page.mdx","depth":1},{"type":"hook","name":"addressesDeleted","description":"This hook is executed after the addresses are deleted. You can consume this hook to perform custom actions.","link":"#addressesDeleted","depth":2}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"DeleteCustomerAddressesWorkflowInput","type":"[DeleteCustomerAddressesWorkflowInput](../../../../types/core_flows.DeleteCustomerAddressesWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"ids","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="deleteCustomerAddressesWorkflow"/>
|
||||
<TypeList types={[{"name":"DeleteCustomerAddressesWorkflowInput","type":"[DeleteCustomerAddressesWorkflowInput](../../../../types/core_flows.DeleteCustomerAddressesWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"The details of the addresses to delete.","expandable":false,"children":[{"name":"ids","type":"`string`[]","description":"The IDs of the addresses to delete.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="deleteCustomerAddressesWorkflow"/>
|
||||
|
||||
## Hooks
|
||||
|
||||
@@ -145,7 +158,7 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
|
||||
|
||||
### addressesDeleted
|
||||
|
||||
This step is a hook that you can inject custom functionality into.
|
||||
This hook is executed after the addresses are deleted. You can consume this hook to perform custom actions.
|
||||
|
||||
#### Example
|
||||
|
||||
|
||||
+17
-13
@@ -13,9 +13,13 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `deleteCustomersWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow deletes one or more customers.
|
||||
This workflow deletes one or more customers. It's used by the
|
||||
[removeCustomerAccountWorkflow](../core_flows.Customer.Workflows_Customer.removeCustomerAccountWorkflow/page.mdx).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/customer/workflows/delete-customers.ts#L18" />
|
||||
You can use this workflow within your customizations or your own custom workflows, allowing you to
|
||||
delete customers in your custom flows.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/customer/workflows/delete-customers.ts#L46" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -36,8 +40,8 @@ export async function POST(
|
||||
const { result } = await deleteCustomersWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"ids": [
|
||||
"id_u8jbRquADYmhFumllb"
|
||||
ids: [
|
||||
"cus_123",
|
||||
]
|
||||
}
|
||||
})
|
||||
@@ -63,8 +67,8 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await deleteCustomersWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"ids": [
|
||||
"id_u8jbRquADYmhFumllb"
|
||||
ids: [
|
||||
"cus_123",
|
||||
]
|
||||
}
|
||||
})
|
||||
@@ -90,8 +94,8 @@ export default async function myCustomJob(
|
||||
const { result } = await deleteCustomersWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"ids": [
|
||||
"id_u8jbRquADYmhFumllb"
|
||||
ids: [
|
||||
"cus_123",
|
||||
]
|
||||
}
|
||||
})
|
||||
@@ -118,8 +122,8 @@ const myWorkflow = createWorkflow(
|
||||
const result = deleteCustomersWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"ids": [
|
||||
"id_u8jbRquADYmhFumllb"
|
||||
ids: [
|
||||
"cus_123",
|
||||
]
|
||||
}
|
||||
})
|
||||
@@ -132,11 +136,11 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"deleteCustomersWorkflow","steps":[{"type":"step","name":"deleteCustomersStep","description":"This step deletes one or more customers.\n\n","link":"../../../Steps_Customer/functions/core_flows.Customer.Steps_Customer.deleteCustomersStep/page.mdx","depth":1},{"type":"hook","name":"customersDeleted","description":"This step is a hook that you can inject custom functionality into.\n\n","link":"#customersDeleted","depth":2},{"type":"step","name":"emitEventStep","description":"Emit an event.\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":3}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"deleteCustomersWorkflow","steps":[{"type":"step","name":"deleteCustomersStep","description":"This step deletes one or more customers.","link":"../../../Steps_Customer/functions/core_flows.Customer.Steps_Customer.deleteCustomersStep/page.mdx","depth":1},{"type":"hook","name":"customersDeleted","description":"This hook is executed after the customers are deleted. You can consume this hook to perform custom actions.","link":"#customersDeleted","depth":2},{"type":"step","name":"emitEventStep","description":"Emit an event.","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":3}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"DeleteCustomersWorkflowInput","type":"[DeleteCustomersWorkflowInput](../../../../types/core_flows.DeleteCustomersWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"ids","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="deleteCustomersWorkflow"/>
|
||||
<TypeList types={[{"name":"DeleteCustomersWorkflowInput","type":"[DeleteCustomersWorkflowInput](../../../../types/core_flows.DeleteCustomersWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"The details of the customers to delete.","expandable":false,"children":[{"name":"ids","type":"`string`[]","description":"The IDs of the customers to delete.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="deleteCustomersWorkflow"/>
|
||||
|
||||
## Hooks
|
||||
|
||||
@@ -146,7 +150,7 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
|
||||
|
||||
### customersDeleted
|
||||
|
||||
This step is a hook that you can inject custom functionality into.
|
||||
This hook is executed after the customers are deleted. You can consume this hook to perform custom actions.
|
||||
|
||||
#### Example
|
||||
|
||||
|
||||
+18
-7
@@ -15,9 +15,20 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `removeCustomerAccountWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
|
||||
|
||||
This workflow deletes a user and remove the association in the auth identity.
|
||||
This workflow deletes a customer and remove its association to its auth identity. It's used by the
|
||||
[Delete Customer Admin API Route](https://docs.medusajs.com/api/admin#customers\_deletecustomersid).
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/customer/workflows/remove-customer-account.ts#L20" />
|
||||
You can use this workflow within your customizations or your own custom workflows, allowing you to
|
||||
delete customer accounts within your custom flows.
|
||||
|
||||
:::note
|
||||
|
||||
This workflow uses the [deleteCustomersWorkflow](../core_flows.Customer.Workflows_Customer.deleteCustomersWorkflow/page.mdx) which has a hook that allows you to perform
|
||||
custom actions after the customers are deleted.
|
||||
|
||||
:::
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/customer/workflows/remove-customer-account.ts#L43" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -38,7 +49,7 @@ export async function POST(
|
||||
const { result } = await removeCustomerAccountWorkflow(req.scope)
|
||||
.run({
|
||||
input: {
|
||||
"customerId": "{value}"
|
||||
customerId: "cus_123"
|
||||
}
|
||||
})
|
||||
|
||||
@@ -63,7 +74,7 @@ export default async function handleOrderPlaced({
|
||||
const { result } = await removeCustomerAccountWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"customerId": "{value}"
|
||||
customerId: "cus_123"
|
||||
}
|
||||
})
|
||||
|
||||
@@ -88,7 +99,7 @@ export default async function myCustomJob(
|
||||
const { result } = await removeCustomerAccountWorkflow(container)
|
||||
.run({
|
||||
input: {
|
||||
"customerId": "{value}"
|
||||
customerId: "cus_123"
|
||||
}
|
||||
})
|
||||
|
||||
@@ -114,7 +125,7 @@ const myWorkflow = createWorkflow(
|
||||
const result = removeCustomerAccountWorkflow
|
||||
.runAsStep({
|
||||
input: {
|
||||
"customerId": "{value}"
|
||||
customerId: "cus_123"
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -126,7 +137,7 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"removeCustomerAccountWorkflow","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":1},{"type":"workflow","name":"deleteCustomersWorkflow","description":"This workflow deletes one or more customers.\n\n","link":"../core_flows.Customer.Workflows_Customer.deleteCustomersWorkflow/page.mdx","depth":2},{"type":"when","condition":"{\n return !!customers[0]?.has_account\n }","depth":"3","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":3},{"type":"step","name":"setAuthAppMetadataStep","description":"This step sets the `app_metadata` property of an auth identity.\n\n","link":"../../../../Auth/Steps_Auth/functions/core_flows.Auth.Steps_Auth.setAuthAppMetadataStep/page.mdx","depth":3}]}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"removeCustomerAccountWorkflow","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":1},{"type":"workflow","name":"deleteCustomersWorkflow","description":"This workflow deletes one or more customers. It's used by the \n[removeCustomerAccountWorkflow](./page.mdx).\n\nYou can use this workflow within your customizations or your own custom workflows, allowing you to \ndelete customers in your custom flows.","link":"../core_flows.Customer.Workflows_Customer.deleteCustomersWorkflow/page.mdx","depth":2},{"type":"when","condition":"{\n return !!customers[0]?.has_account\n }","depth":"3","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":3},{"type":"step","name":"setAuthAppMetadataStep","description":"This step sets the `app_metadata` property of an auth identity. This is useful to\nassociate a user (whether it's an admin user or customer) with an auth identity\nthat allows them to authenticate into Medusa.\n\nYou can learn more about auth identites in \n[this documentation](https://docs.medusajs.com/resources/commerce-modules/auth/auth-identity-and-actor-types).\n\nTo use this for a custom actor type, check out [this guide](https://docs.medusajs.com/resources/commerce-modules/auth/create-actor-type)\nthat explains how to create a custom `manager` actor type and manage its users.","link":"../../../../Auth/Steps_Auth/functions/core_flows.Auth.Steps_Auth.setAuthAppMetadataStep/page.mdx","depth":3}]}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
|
||||
+4
-4
@@ -18,9 +18,9 @@ and the [Update Customer Address Store API Route](https://docs.medusajs.com/api/
|
||||
This workflow has a hook that allows you to perform custom actions on the updated customer addresses. For example, you can pass under `additional_data` custom data that
|
||||
allows you to update custom data models linked to the addresses.
|
||||
|
||||
You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around updating customer addresses.
|
||||
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around updating customer addresses.
|
||||
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/1b86c17b7293f3b810c062d78ec6ef563f968366/packages/core/core-flows/src/customer/workflows/update-addresses.ts#L65" />
|
||||
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/e3d5457b5c990bb230daebe316ee2486913c27f6/packages/core/core-flows/src/customer/workflows/update-addresses.ts#L66" />
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -161,11 +161,11 @@ const myWorkflow = createWorkflow(
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"updateCustomerAddressesWorkflow","steps":[{"type":"step","name":"maybeUnsetDefaultShippingAddressesStep","description":"This step unsets the `is_default_shipping` property of one or more addresses.\n\n","link":"../../../Steps_Customer/functions/core_flows.Customer.Steps_Customer.maybeUnsetDefaultShippingAddressesStep/page.mdx","depth":1},{"type":"step","name":"maybeUnsetDefaultBillingAddressesStep","description":"This step unsets the `is_default_billing` property of one or more addresses.\n\n","link":"../../../Steps_Customer/functions/core_flows.Customer.Steps_Customer.maybeUnsetDefaultBillingAddressesStep/page.mdx","depth":1},{"type":"step","name":"updateCustomerAddressesStep","description":"This step updates one or more customer addresses.\n\n","link":"../../../Steps_Customer/functions/core_flows.Customer.Steps_Customer.updateCustomerAddressesStep/page.mdx","depth":2},{"type":"hook","name":"addressesUpdated","description":"This hook is executed after the addresses are updated. You can consume this hook to perform custom actions on the updated addresses.\n\n","link":"#addressesUpdated","depth":3}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"updateCustomerAddressesWorkflow","steps":[{"type":"step","name":"maybeUnsetDefaultShippingAddressesStep","description":"This step unsets the `is_default_billing` property of existing customer addresses\nif the `is_default_billing` property in the addresses in the input is set to `true`.","link":"../../../Steps_Customer/functions/core_flows.Customer.Steps_Customer.maybeUnsetDefaultShippingAddressesStep/page.mdx","depth":1},{"type":"step","name":"maybeUnsetDefaultBillingAddressesStep","description":"This step unsets the `is_default_billing` property of existing customer addresses\nif the `is_default_billing` property in the addresses in the input is set to `true`.","link":"../../../Steps_Customer/functions/core_flows.Customer.Steps_Customer.maybeUnsetDefaultBillingAddressesStep/page.mdx","depth":1},{"type":"step","name":"updateCustomerAddressesStep","description":"This step updates one or more customer addresses.","link":"../../../Steps_Customer/functions/core_flows.Customer.Steps_Customer.updateCustomerAddressesStep/page.mdx","depth":2},{"type":"hook","name":"addressesUpdated","description":"This hook is executed after the addresses are updated. You can consume this hook to perform custom actions on the updated addresses.","link":"#addressesUpdated","depth":3}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
<TypeList types={[{"name":"object & AdditionalData","type":"`object` & [AdditionalData](../../../../../types/HttpTypes/types/types.HttpTypes.AdditionalData/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"selector","type":"[FilterableCustomerAddressProps](../../../../../customer/interfaces/customer.FilterableCustomerAddressProps/page.mdx)","description":"The filters to select the addresses to update.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Searches for addresses by properties such as name and street using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"The IDs to filter the customer address by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`string` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<string>","description":"Filter addresses by name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<boolean>","description":"Filter addresses by whether they're the default for shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<boolean>","description":"Filter addresses by whether they're the default for billing.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"`string` \\| `string`[]","description":"Filter addresses by the associated customer's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer","type":"`string` \\| `string`[] \\| [FilterableCustomerProps](../../../../../customer/interfaces/customer.FilterableCustomerProps/page.mdx)","description":"Filter addresses by the associated customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`string` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<string>","description":"Filter addresses by company.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`string` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<string>","description":"Filter addresses by first name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`string` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<string>","description":"Filter addresses by last name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`string` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<string>","description":"Filter addresses by first address line.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`string` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<string>","description":"Filter addresses by second address line.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`string` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<string>","description":"Filter addresses by city.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<string>","description":"Filter addresses by country code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`string` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<string>","description":"Filter addresses by province.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`string` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<string>","description":"Filter addresses by postal code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`string` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<string>","description":"Filter addresses by phone number.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<Record<string, unknown>>","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":Line truncated
|
||||
<TypeList types={[{"name":"UpdateCustomerAddressesWorkflowInput","type":"[UpdateCustomerAddressesWorkflowInput](../../../../types/core_flows.UpdateCustomerAddressesWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"The data to update one or more customer addresses, along with custom data that's passed to the workflow's hooks.","expandable":false,"children":[{"name":"selector","type":"[FilterableCustomerAddressProps](../../../../../customer/interfaces/customer.FilterableCustomerAddressProps/page.mdx)","description":"The filters to select the addresses to update.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Searches for addresses by properties such as name and street using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"The IDs to filter the customer address by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`string` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<string>","description":"Filter addresses by name.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"$and","type":"[Query](../../../../../customer/types/customer.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$or","type":"[Query](../../../../../customer/types/customer.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$eq","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T> \\| [ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ne","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$in","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$nin","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$not","type":"[Query](../../../../../customer/types/customer.Query/page.mdx)<T>","description":"API wrapper around the remoteQuery","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gt","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$gte","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lt","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$lte","type":"[ExpandScalar](../../../../../customer/types/customer.ExpandScalar/page.mdx)<T>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$like","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$re","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$ilike","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$fulltext","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$overlap","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contains","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$contained","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$exists","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"is_default_shipping","type":"`boolean` \\| [OperatorMap](../../../../../customer/types/customer.OperatorMap/page.mdx)<boolean>","description":"Filter addresses by whether they're the default for shipping.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"$and","type":"[Query](../../../../../customer/types/customer.Query/page.mdx)<T>[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$or","typeLine truncated
|
||||
|
||||
## Output
|
||||
|
||||
|
||||
Loaded 100 of 1055 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user