docs: generate event references (#12378)

This commit is contained in:
Shahed Nasser authored and GitHub committed 2025-05-06 16:59:30 +03:00
1 parent a16ffb83d9
commit 97dd520c64
98 files changed
+309960 -303294

No files matched your search

@@ -24,7 +24,9 @@ const MDXComponents: MDXComponentsType = {
CodeTab,
Table,
Badge,
Tooltip,
Tooltip: (props) => {
return <Tooltip {...props} />
},
}
export default MDXComponents
@@ -19,7 +19,7 @@ This workflow creates one or more API keys, which can be secret or publishable.
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/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/api-key/workflows/create-api-keys.ts#L51" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/6f8ffcf53c709d40dfeb5980f3769cd0bb810e3e/packages/core/core-flows/src/api-key/workflows/create-api-keys.ts#L51" />
## Examples
@@ -162,6 +162,22 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### apiKeysCreated
This step is a hook that you can inject custom functionality into.
#### Example
```ts
import { createApiKeysWorkflow } from "@medusajs/medusa/core-flows"
createApiKeysWorkflow.hooks.apiKeysCreated(
(async ({ apiKeys }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"apiKeys","type":"[ApiKeyDTO](../../../../../api_key/interfaces/api_key.ApiKeyDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","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="apiKeysCreated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Api_Key.Workflows_Api_Key/page.mdx#__type)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"apiKeys","type":"[ApiKeyDTO](../../../../../api_key/interfaces/api_key.ApiKeyDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","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="apiKeysCreated"/>
@@ -27,7 +27,7 @@ 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/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/auth/workflows/generate-reset-password-token.ts#L42" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/auth/workflows/generate-reset-password-token.ts#L42" />
## Examples
@@ -157,3 +157,45 @@ const myWorkflow = createWorkflow(
## Output
<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="generateResetPasswordTokenWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`auth.password_reset`
</Table.Cell>
<Table.Cell>
Emitted when a reset password token is generated. You can listen to this event
to send a reset password email to the user or customer, for example.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
entity_id, // The identifier of the user or customer. For example, an email address.
actor_type, // The type of actor. For example, "customer", "user", or custom.
token, // The generated token.
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -27,7 +27,7 @@ This workflow adds a shipping method to a cart. It's executed by the
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/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/cart/workflows/add-shipping-method-to-cart.ts#L81" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/cart/workflows/add-shipping-method-to-cart.ts#L81" />
## Examples
@@ -190,6 +190,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### 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":"","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"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Cart.Workflows_Cart/page.mdx#__type)","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"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`cart.updated`
</Table.Cell>
<Table.Cell>
Emitted when a cart's details are updated.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
id, // The ID of the cart
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -29,7 +29,7 @@ This workflow adds a product variant to a cart as a line item. It's executed by
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/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/cart/workflows/add-to-cart.ts#L108" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/cart/workflows/add-to-cart.ts#L108" />
## Examples
@@ -266,3 +266,42 @@ addToCartWorkflow.hooks.setPricingContext(
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Cart.Workflows_Cart/page.mdx#__type-2)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variantIds","type":"(`undefined` \\| `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":"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":"unit_price","type":"[BigNumberInput](../../../../../types/types/types.BigNumberInput/page.mdx)","description":"The price of a single quantity of the item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Custom key-value pairs related to the item.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefLine truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`cart.updated`
</Table.Cell>
<Table.Cell>
Emitted when a cart's details are updated.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
id, // The ID of the cart
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -29,7 +29,7 @@ You can use this workflow within your own customizations or custom workflows, al
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/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/cart/workflows/complete-cart.ts#L87" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/cart/workflows/complete-cart.ts#L87" />
## Examples
@@ -156,6 +156,62 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### 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 { completeCartWorkflow } from "@medusajs/medusa/core-flows"
completeCartWorkflow.hooks.validate(
(async ({ input, cart }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[CompleteCartWorkflowInput](../../../../types/core_flows.CompleteCartWorkflowInput/page.mdx)","description":"The data to complete a cart and place an order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart to complete.","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"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Cart.Workflows_Cart/page.mdx#__type-3)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[CompleteCartWorkflowInput](../../../../types/core_flows.CompleteCartWorkflowInput/page.mdx)","description":"The data to complete a cart and place an order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the cart to complete.","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"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`order.placed`
</Table.Cell>
<Table.Cell>
Emitted when an order is placed, or when a draft order is converted to an
order.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
id, // The ID of the order
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -32,7 +32,7 @@ This workflow has a hook that allows you to perform custom actions on the create
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/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/cart/workflows/create-carts.ts#L115" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/cart/workflows/create-carts.ts#L115" />
## Examples
@@ -288,3 +288,42 @@ createCartWorkflow.hooks.cartCreated(
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Cart.Workflows_Cart/page.mdx#__type-7)","description":"The input data for the hook.","optional":false,"defaultValue":"","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":"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":"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":"item_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The item total of the cart.","optional":false,"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":"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":"original_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The original subtotal of the cart.","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.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The subtotal of the cart. (Excluding taxes)","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The tax total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The discount total of the cart.","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.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"gift_card_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The gift card total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"gift_card_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The gift card tax total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The shipping total of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_subtotal","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The shipping subtotal of the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_tax_total","type":"[BigNumberValue](../../../../../cart/types/cart.BigNumberValue/page.mdx)","description":"The shipping tax total of the cart.","optional":false,"defaultValue":"","expandable":false,"Line truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`cart.created`
</Table.Cell>
<Table.Cell>
Emitted when a cart is created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
id, // The ID of the cart
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -27,7 +27,7 @@ use the [listShippingOptionsForCartWithPricingWorkflow](../core_flows.Cart.Workf
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/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/cart/workflows/list-shipping-options-for-cart.ts#L82" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/6f8ffcf53c709d40dfeb5980f3769cd0bb810e3e/packages/core/core-flows/src/cart/workflows/list-shipping-options-for-cart.ts#L82" />
## Examples
@@ -154,6 +154,55 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### setPricingContext
This hook is executed before the shipping options are retrieved. You can consume this hook to return any custom context useful for the prices retrieval of shipping options.
For example, assuming you have the following custom pricing rule:
```json
{
"attribute": "location_id",
"operator": "eq",
"value": "sloc_123",
}
```
You can consume the `setPricingContext` hook to add the `location_id` context to the prices calculation:
```ts
import { listShippingOptionsForCartWorkflow } from "@medusajs/medusa/core-flows";
import { StepResponse } from "@medusajs/workflows-sdk";
listShippingOptionsForCartWorkflow.hooks.setPricingContext((
{ cart, fulfillmentSetIds, additional_data }, { container }
) => {
return new StepResponse({
location_id: "sloc_123", // Special price for in-store purchases
});
});
```
The shipping options' prices will now be retrieved using the context you return.
:::note
Learn more about prices calculation context in the [Prices Calculation](https://docs.medusajs.com/resources/commerce-modules/pricing/price-calculation) documentation.
:::
#### Example
```ts
import { listShippingOptionsForCartWorkflow } from "@medusajs/medusa/core-flows"
listShippingOptionsForCartWorkflow.hooks.setPricingContext(
(async ({ cart, fulfillmentSetIds, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillmentSetIds","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="setPricingContext"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Cart.Workflows_Cart/page.mdx#__type-9)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillmentSetIds","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="setPricingContext"/>
@@ -21,7 +21,7 @@ and retrieve their correct pricing after a cart update. This workflow is used by
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/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/cart/workflows/refresh-cart-shipping-methods.ts#L52" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/6f8ffcf53c709d40dfeb5980f3769cd0bb810e3e/packages/core/core-flows/src/cart/workflows/refresh-cart-shipping-methods.ts#L52" />
## Examples
@@ -144,6 +144,22 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### 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 { refreshCartShippingMethodsWorkflow } from "@medusajs/medusa/core-flows"
refreshCartShippingMethodsWorkflow.hooks.validate(
(async ({ input, cart }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[RefreshCartShippingMethodsWorkflowInput](../../../../types/core_flows.RefreshCartShippingMethodsWorkflowInput/page.mdx)","description":"The details of the cart to refresh.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"cart","type":"`any`","description":"The Cart reference.","optional":true,"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"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Cart.Workflows_Cart/page.mdx#__type-12)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[RefreshCartShippingMethodsWorkflowInput](../../../../types/core_flows.RefreshCartShippingMethodsWorkflowInput/page.mdx)","description":"The details of the cart to refresh.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"cart","type":"`any`","description":"The Cart reference.","optional":true,"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"/>
@@ -25,7 +25,7 @@ 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/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/cart/workflows/refresh-payment-collection.ts#L56" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/6f8ffcf53c709d40dfeb5980f3769cd0bb810e3e/packages/core/core-flows/src/cart/workflows/refresh-payment-collection.ts#L56" />
## Examples
@@ -148,6 +148,22 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### 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 { refreshPaymentCollectionForCartWorkflow } from "@medusajs/medusa/core-flows"
refreshPaymentCollectionForCartWorkflow.hooks.validate(
(async ({ input, cart }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[RefreshPaymentCollectionForCartWorklowInput](../../../../types/core_flows.RefreshPaymentCollectionForCartWorklowInput/page.mdx)","description":"The details of the cart to refresh.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"cart","type":"`any`","description":"The Cart reference.","optional":true,"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"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Cart.Workflows_Cart/page.mdx#__type-13)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[RefreshPaymentCollectionForCartWorklowInput](../../../../types/core_flows.RefreshPaymentCollectionForCartWorklowInput/page.mdx)","description":"The details of the cart to refresh.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"cart","type":"`any`","description":"The Cart reference.","optional":true,"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"/>
@@ -27,7 +27,7 @@ by the [Set Cart's Customer Store API Route](https://docs.medusajs.com/api/store
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/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/cart/workflows/transfer-cart-customer.ts#L50" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/6f8ffcf53c709d40dfeb5980f3769cd0bb810e3e/packages/core/core-flows/src/cart/workflows/transfer-cart-customer.ts#L50" />
## Examples
@@ -154,6 +154,22 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### 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 { transferCartCustomerWorkflow } from "@medusajs/medusa/core-flows"
transferCartCustomerWorkflow.hooks.validate(
(async ({ input, cart }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[TransferCartCustomerWorkflowInput](../../../../types/core_flows.TransferCartCustomerWorkflowInput/page.mdx)","description":"The cart ownership transfer details.","optional":false,"defaultValue":"","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":[]}]},{"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"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Cart.Workflows_Cart/page.mdx#__type-14)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[TransferCartCustomerWorkflowInput](../../../../types/core_flows.TransferCartCustomerWorkflowInput/page.mdx)","description":"The cart ownership transfer details.","optional":false,"defaultValue":"","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":[]}]},{"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"/>
@@ -22,7 +22,7 @@ that need to be applied to the cart's line items and shipping methods based on t
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/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/cart/workflows/update-cart-promotions.ts#L75" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/6f8ffcf53c709d40dfeb5980f3769cd0bb810e3e/packages/core/core-flows/src/cart/workflows/update-cart-promotions.ts#L75" />
## Examples
@@ -157,6 +157,22 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### 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 { updateCartPromotionsWorkflow } from "@medusajs/medusa/core-flows"
updateCartPromotionsWorkflow.hooks.validate(
(async ({ input, cart }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[UpdateCartPromotionsWorkflowInput](../../../../types/core_flows.UpdateCartPromotionsWorkflowInput/page.mdx)","description":"The details of the promotion updates on a cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"cart","type":"`any`","description":"The Cart reference.","optional":true,"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":[]}]},{"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"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Cart.Workflows_Cart/page.mdx#__type-18)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[UpdateCartPromotionsWorkflowInput](../../../../types/core_flows.UpdateCartPromotionsWorkflowInput/page.mdx)","description":"The details of the promotion updates on a cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"cart","type":"`any`","description":"The Cart reference.","optional":true,"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":[]}]},{"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"/>
@@ -39,7 +39,7 @@ then update any associated details related to the cart in the workflow's hook.
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/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/cart/workflows/update-cart.ts#L83" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/cart/workflows/update-cart.ts#L83" />
## Examples
@@ -255,3 +255,73 @@ updateCartWorkflow.hooks.cartUpdated(
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Cart.Workflows_Cart/page.mdx#__type-17)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="cartUpdated"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`cart.updated`
</Table.Cell>
<Table.Cell>
Emitted when a cart's details are updated.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
id, // The ID of the cart
}
```
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`cart.customer_updated`
</Table.Cell>
<Table.Cell>
Emitted when the customer in the cart is updated.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
id, // The ID of the cart
}
```
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`cart.region_updated`
</Table.Cell>
<Table.Cell>
Emitted when the cart's region is updated. This
event is emitted alongside the `cart.updated` event.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
id, // The ID of the cart
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -28,7 +28,7 @@ by the [Update Line Item Store API Route](https://docs.medusajs.com/api/store#ca
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/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/cart/workflows/update-line-item-in-cart.ts#L89" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/cart/workflows/update-line-item-in-cart.ts#L89" />
## Examples
@@ -241,3 +241,42 @@ updateLineItemInCartWorkflow.hooks.setPricingContext(
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Cart.Workflows_Cart/page.mdx#__type-20)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variantIds","type":"`any`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="setPricingContext"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`cart.updated`
</Table.Cell>
<Table.Cell>
Emitted when a cart's details are updated.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
id, // The ID of the cart
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -24,7 +24,7 @@ Learn more about basic authentication flows in [this documentation](https://docs
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/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/customer/workflows/create-customer-account.ts#L54" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/customer/workflows/create-customer-account.ts#L54" />
## Examples
@@ -162,3 +162,42 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"CustomerDTO","type":"[CustomerDTO](../../../../../customer/interfaces/customer.CustomerDTO/page.mdx)","optional":false,"defaultValue":"","description":"The customer details.","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":false,"children":[]}]},{"name":"phone","type":"`null` \\| `string`","description":"The phone of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"groups","type":"`object`[]","description":"The groups of theLine truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`customer.created`
</Table.Cell>
<Table.Cell>
Emitted when a customer is created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the customer
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -21,7 +21,7 @@ allows you to create custom data models linked to the 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/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/customer/workflows/create-addresses.ts#L75" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/customer/workflows/create-addresses.ts#L75" />
## Examples
@@ -232,6 +232,22 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### addressesCreated
This hook is executed after the addresses are created. You can consume this hook to perform custom actions on the created addresses.
#### Example
```ts
import { createCustomerAddressesWorkflow } from "@medusajs/medusa/core-flows"
createCustomerAddressesWorkflow.hooks.addressesCreated(
(async ({ addresses, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"addresses","type":"[CustomerAddressDTO](../../../../../customer/interfaces/customer.CustomerAddressDTO/page.mdx)[]","description":"","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":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="addressesCreated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Customer.Workflows_Customer/page.mdx#__type)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"addresses","type":"[CustomerAddressDTO](../../../../../customer/interfaces/customer.CustomerAddressDTO/page.mdx)[]","description":"","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":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="addressesCreated"/>
@@ -20,7 +20,7 @@ This workflow has a hook that allows you to perform custom actions on the create
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/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/customer/workflows/create-customers.ts#L54" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/customer/workflows/create-customers.ts#L54" />
## Examples
@@ -175,6 +175,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### customersCreated
This hook is executed after the customers are created. You can consume this hook to perform custom actions on the created customers.
#### Example
```ts
import { createCustomersWorkflow } from "@medusajs/medusa/core-flows"
createCustomersWorkflow.hooks.customersCreated(
(async ({ customers, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"customers","type":"[CustomerDTO](../../../../../customer/interfaces/customer.CustomerDTO/page.mdx)[]","description":"","optional":false,"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":"phone","type":"`null` \\| `string`","description":"The phone of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"groups","type":"`object`[]","description":"The groups of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"Who created the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `string` \\| `Date`","description":"The deletion date of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The creation date of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The update date of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="customersCreated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Customer.Workflows_Customer/page.mdx#__type-1)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"customers","type":"[CustomerDTO](../../../../../customer/interfaces/customer.CustomerDTO/page.mdx)[]","description":"","optional":false,"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":"phone","type":"`null` \\| `string`","description":"The phone of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"groups","type":"`object`[]","description":"The groups of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"Who created the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `string` \\| `Date`","description":"The deletion date of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The creation date of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The update date of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="customersCreated"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`customer.created`
</Table.Cell>
<Table.Cell>
Emitted when a customer is created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the customer
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -28,7 +28,7 @@ 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/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/customer/workflows/delete-addresses.ts#L52" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/customer/workflows/delete-addresses.ts#L52" />
## Examples
@@ -159,6 +159,22 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### addressesDeleted
This hook is executed after the addresses are deleted. You can consume this hook to perform custom actions.
#### Example
```ts
import { deleteCustomerAddressesWorkflow } from "@medusajs/medusa/core-flows"
deleteCustomerAddressesWorkflow.hooks.addressesDeleted(
(async ({ ids }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","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="addressesDeleted"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Customer.Workflows_Customer/page.mdx#__type-2)","description":"The input data for the hook.","optional":false,"defaultValue":"","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="addressesDeleted"/>
@@ -20,7 +20,7 @@ This workflow deletes one or more customers. It's used by the
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/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/customer/workflows/delete-customers.ts#L46" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/customer/workflows/delete-customers.ts#L46" />
## Examples
@@ -151,6 +151,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### customersDeleted
This hook is executed after the customers are deleted. You can consume this hook to perform custom actions.
#### Example
```ts
import { deleteCustomersWorkflow } from "@medusajs/medusa/core-flows"
deleteCustomersWorkflow.hooks.customersDeleted(
(async ({ ids }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","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="customersDeleted"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Customer.Workflows_Customer/page.mdx#__type-3)","description":"The input data for the hook.","optional":false,"defaultValue":"","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="customersDeleted"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`customer.deleted`
</Table.Cell>
<Table.Cell>
Emitted when a customer is deleted.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the customer
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -29,7 +29,7 @@ custom actions after the customers are deleted.
:::
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/customer/workflows/remove-customer-account.ts#L43" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/customer/workflows/remove-customer-account.ts#L43" />
## Examples
@@ -147,3 +147,42 @@ const myWorkflow = createWorkflow(
## Output
<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="removeCustomerAccountWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`customer.deleted`
</Table.Cell>
<Table.Cell>
Emitted when a customer is deleted.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the customer
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -21,7 +21,7 @@ allows you to update custom data models linked to the 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/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/customer/workflows/update-addresses.ts#L66" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/customer/workflows/update-addresses.ts#L66" />
## Examples
@@ -180,6 +180,22 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### addressesUpdated
This hook is executed after the addresses are updated. You can consume this hook to perform custom actions on the updated addresses.
#### Example
```ts
import { updateCustomerAddressesWorkflow } from "@medusajs/medusa/core-flows"
updateCustomerAddressesWorkflow.hooks.addressesUpdated(
(async ({ addresses, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"addresses","type":"[CustomerAddressDTO](../../../../../customer/interfaces/customer.CustomerAddressDTO/page.mdx)[]","description":"","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":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="addressesUpdated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Customer.Workflows_Customer/page.mdx#__type-4)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"addresses","type":"[CustomerAddressDTO](../../../../../customer/interfaces/customer.CustomerAddressDTO/page.mdx)[]","description":"","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":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="addressesUpdated"/>
@@ -22,7 +22,7 @@ custom data models linked to the customers.
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around updating customers.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/customer/workflows/update-customers.ts#L60" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/customer/workflows/update-customers.ts#L60" />
## Examples
@@ -169,6 +169,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### customersUpdated
This hook is executed after the customers are updated. You can consume this hook to perform custom actions on the updated customers.
#### Example
```ts
import { updateCustomersWorkflow } from "@medusajs/medusa/core-flows"
updateCustomersWorkflow.hooks.customersUpdated(
(async ({ customers, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"customers","type":"[CustomerDTO](../../../../../customer/interfaces/customer.CustomerDTO/page.mdx)[]","description":"","optional":false,"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":"phone","type":"`null` \\| `string`","description":"The phone of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"groups","type":"`object`[]","description":"The groups of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"Who created the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `string` \\| `Date`","description":"The deletion date of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The creation date of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The update date of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="customersUpdated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Customer.Workflows_Customer/page.mdx#__type-5)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"customers","type":"[CustomerDTO](../../../../../customer/interfaces/customer.CustomerDTO/page.mdx)[]","description":"","optional":false,"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":"phone","type":"`null` \\| `string`","description":"The phone of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"groups","type":"`object`[]","description":"The groups of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"Who created the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `string` \\| `Date`","description":"The deletion date of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The creation date of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The update date of the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="customersUpdated"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`customer.updated`
</Table.Cell>
<Table.Cell>
Emitted when a customer is updated.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the customer
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -26,7 +26,7 @@ using [requestDraftOrderEditWorkflow](../core_flows.Draft_Order.Workflows_Draft_
You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around
updating a draft order.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/6f8ffcf53c709d40dfeb5980f3769cd0bb810e3e/packages/core/core-flows/src/draft-order/workflows/update-draft-order.ts#L149" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/draft-order/workflows/update-draft-order.ts#L149" />
## Examples
@@ -152,3 +152,43 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"OrderPreviewDTO","type":"[OrderPreviewDTO](../../../../../order/interfaces/order.OrderPreviewDTO/page.mdx)","optional":false,"defaultValue":"","description":"The details of an order after a change is applied on it.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"version","type":"`number`","description":"The version of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The order's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[OrderStatus](../../../../../order/types/order.OrderStatus/page.mdx)","description":"The status of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the order was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the order was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"original_item_subtotal","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"original_item_tax_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"item_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"item_subtotal","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../.Line truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`order.updated`
</Table.Cell>
<Table.Cell>
Emitted when the details of an order or draft order is updated. This
doesn't include updates made by an edit.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
id, // The ID of the order
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -25,7 +25,7 @@ using the [Retrieve Registration JWT Token API Route](https://docs.medusajs.com/
You can use this workflow within your customizations or your own custom workflows, allowing you to
accept invites within your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/invite/workflows/accept-invite.ts#L46" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/invite/workflows/accept-invite.ts#L46" />
## Examples
@@ -167,3 +167,57 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"UserDTO[]","type":"[UserDTO](../../../../../user/interfaces/user.UserDTO/page.mdx)[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"The email of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"avatar_url","type":"`null` \\| `string`","description":"The avatar URL of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The creation date of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The updated date of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="acceptInviteWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`user.created`
</Table.Cell>
<Table.Cell>
Emitted when users are created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the user
}]
```
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`invite.accepted`
</Table.Cell>
<Table.Cell>
Emitted when an invite is accepted.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
id, // The ID of the invite
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -20,7 +20,7 @@ This workflow creates one or more user invites. It's used by the
You can use this workflow within your customizations or your own custom workflows, allowing you to
create invites within your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/invite/workflows/create-invites.ts#L35" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/invite/workflows/create-invites.ts#L35" />
## Examples
@@ -146,3 +146,43 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"InviteDTO[]","type":"[InviteDTO](../../../../../user/interfaces/user.InviteDTO/page.mdx)[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the invite.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"The email of the invite.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"accepted","type":"`boolean`","description":"Whether the invite is accepted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"token","type":"`string`","description":"The token of the invite.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"expires_at","type":"`Date`","description":"The invite's expiry date.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The invite's creation date.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The invite's update date.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The invite's deletion date.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createInvitesWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`invite.created`
</Table.Cell>
<Table.Cell>
Emitted when invites are created. You can listen to this event
to send an email to the invited users, for example.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the invite
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -20,7 +20,7 @@ This workflow deletes one or more user invites. It's used by the
You can use this workflow within your customizations or your own custom workflows, allowing you to
delete invites within your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/invite/workflows/delete-invites.ts#L31" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/invite/workflows/delete-invites.ts#L31" />
## Examples
@@ -134,3 +134,42 @@ const myWorkflow = createWorkflow(
## Input
<TypeList types={[{"name":"DeleteInvitesWorkflowInput","type":"[DeleteInvitesWorkflowInput](../../../../../types/WorkflowTypes/InviteWorkflow/interfaces/types.WorkflowTypes.InviteWorkflow.DeleteInvitesWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"ids","type":"`string`[]","description":"The IDs of the invites 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="deleteInvitesWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`invite.deleted`
</Table.Cell>
<Table.Cell>
Emitted when invites are deleted.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the invite
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -24,7 +24,7 @@ which you can listen to in a [Subscriber](https://docs.medusajs.com/learn/fundam
You can use this workflow within your customizations or your own custom workflows, allowing you to
refresh invite tokens within your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/invite/workflows/refresh-invite-tokens.ts#L37" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/invite/workflows/refresh-invite-tokens.ts#L37" />
## Examples
@@ -142,3 +142,44 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"InviteDTO[]","type":"[InviteDTO](../../../../../user/interfaces/user.InviteDTO/page.mdx)[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the invite.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"The email of the invite.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"accepted","type":"`boolean`","description":"Whether the invite is accepted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"token","type":"`string`","description":"The token of the invite.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"expires_at","type":"`Date`","description":"The invite's expiry date.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The invite's creation date.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The invite's update date.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The invite's deletion date.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="refreshInviteTokensWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`invite.resent`
</Table.Cell>
<Table.Cell>
Emitted when invites should be resent because their token was
refreshed. You can listen to this event to send an email to the invited users,
for example.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the invite
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -24,7 +24,7 @@ an order. It's used by other workflows, such as [orderEditAddNewItemWorkflow](..
You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around adding items to
an order.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/add-line-items.ts#L123" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/add-line-items.ts#L123" />
## Examples
@@ -167,6 +167,56 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### setPricingContext
This hook is executed after the order is retrieved and before the line items are created. You can consume this hook to return any custom context useful for the prices retrieval of the variants to be added to the order.
For example, assuming you have the following custom pricing rule:
```json
{
"attribute": "location_id",
"operator": "eq",
"value": "sloc_123",
}
```
You can consume the `setPricingContext` hook to add the `location_id` context to the prices calculation:
```ts
import { addOrderLineItemsWorkflow } from "@medusajs/medusa/core-flows";
import { StepResponse } from "@medusajs/workflows-sdk";
addOrderLineItemsWorkflow.hooks.setPricingContext((
{ order, variantIds, region, customerData, additional_data }, { container }
) => {
return new StepResponse({
location_id: "sloc_123", // Special price for in-store purchases
});
});
```
The variants' prices will now be retrieved using the context you return.
:::note
Learn more about prices calculation context in the [Prices Calculation](https://docs.medusajs.com/resources/commerce-modules/pricing/price-calculation) documentation.
:::
#### Example
```ts
import { addOrderLineItemsWorkflow } from "@medusajs/medusa/core-flows"
addOrderLineItemsWorkflow.hooks.setPricingContext(
(async ({ order, variantIds, region, customerData,
additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"order","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variantIds","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region","type":"[RegionDTO](../../../../../region/interfaces/region.RegionDTO/page.mdx)","description":"The region details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency code of the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"automatic_taxes","type":"`boolean`","description":"Setting to indicate whether taxes need to be applied automatically","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"countries","type":"[RegionCountryDTO](../../../../../region/interfaces/region.RegionCountryDTO/page.mdx)[]","description":"The countries of the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_providers","type":"[PaymentProviderDTO](../../../../../region/interfaces/region.PaymentProviderDTO/page.mdx)[]","description":"Payment providers available in the region","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string`","description":"The date the region was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"The date the region was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, any>`","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customerData","type":"[FindOrCreateCustomerOutputStepOutput](../../../../interfaces/core_flows.FindOrCreateCustomerOutputStepOutput/page.mdx)","description":"The details of the customer found or created.","optional":false,"defaultValue":"","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":"email","type":"`null` \\| `string`","description":"The email of the customer found or created, if any.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="setPricingContext"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Order.Workflows_Order/page.mdx#__type)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"order","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variantIds","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region","type":"[RegionDTO](../../../../../region/interfaces/region.RegionDTO/page.mdx)","description":"The region details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency code of the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"automatic_taxes","type":"`boolean`","description":"Setting to indicate whether taxes need to be applied automatically","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"countries","type":"[RegionCountryDTO](../../../../../region/interfaces/region.RegionCountryDTO/page.mdx)[]","description":"The countries of the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_providers","type":"[PaymentProviderDTO](../../../../../region/interfaces/region.PaymentProviderDTO/page.mdx)[]","description":"Payment providers available in the region","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string`","description":"The date the region was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"The date the region was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, any>`","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customerData","type":"[FindOrCreateCustomerOutputStepOutput](../../../../interfaces/core_flows.FindOrCreateCustomerOutputStepOutput/page.mdx)","description":"The details of the customer found or created.","optional":false,"defaultValue":"","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":"email","type":"`null` \\| `string`","description":"The email of the customer found or created, if any.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="setPricingContext"/>
@@ -19,7 +19,7 @@ This workflow archives one or more orders. It's used by the
You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around archiving orders.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/archive-orders.ts#L46" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/archive-orders.ts#L46" />
## Examples
@@ -137,3 +137,42 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"ArchiveOrdersWorkflowOutput","type":"[ArchiveOrdersWorkflowOutput](../../../../types/core_flows.ArchiveOrdersWorkflowOutput/page.mdx)","optional":false,"defaultValue":"","description":"The archived orders.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"version","type":"`number`","description":"The version of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The order's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[OrderStatus](../../../../../fulfillment/types/fulfillment.OrderStatus/page.mdx)","description":"The status of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the order was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the order was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../fulfillment/types/fulfillment.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":"original_item_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../fulfillment/types/fulfillment.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":"original_item_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../fulfillment/types/fulfillment.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":"item_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../fulfillment/types/fulfillment.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":"item_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optionLine truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`order.archived`
</Table.Cell>
<Table.Cell>
Emitted when an order is archived.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the order
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -5,6 +5,7 @@ sidebar_description: Cancel a requested order edit.
tags:
- remote query
- order
- event bus
- workflow
---
@@ -20,7 +21,7 @@ This workflow cancels a requested edit for an order. It's used by the
You can use this workflow within your customizations or your own custom workflows, allowing you to cancel an order edit
in your custom flow.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/order-edit/cancel-begin-order-edit.ts#L95" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/order-edit/cancel-begin-order-edit.ts#L99" />
## Examples
@@ -129,8 +130,48 @@ const myWorkflow = createWorkflow(
## Steps
<WorkflowDiagram workflow={{"name":"cancelBeginOrderEditWorkflow","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":"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":"cancelBeginOrderEditValidationStep","description":"This step validates that a requested order edit can be canceled.\nIf the order is canceled or the order change is not active, the step will throw an error.\n\n:::note\n\nYou can retrieve an order and order change 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":"../core_flows.Order.Workflows_Order.cancelBeginOrderEditValidationStep/page.mdx","depth":3},{"type":"step","name":"deleteOrderChangesStep","description":"This step deletes order changes.","link":"../../../Steps_Order/functions/core_flows.Order.Steps_Order.deleteOrderChangesStep/page.mdx","depth":4},{"type":"step","name":"deleteOrderShippingMethods","description":"This step deletes order shipping methods.","link":"../../../Steps_Order/functions/core_flows.Order.Steps_Order.deleteOrderShippingMethods/page.mdx","depth":4}]}} />
<WorkflowDiagram workflow={{"name":"cancelBeginOrderEditWorkflow","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":"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":"cancelBeginOrderEditValidationStep","description":"This step validates that a requested order edit can be canceled.\nIf the order is canceled or the order change is not active, the step will throw an error.\n\n:::note\n\nYou can retrieve an order and order change 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":"../core_flows.Order.Workflows_Order.cancelBeginOrderEditValidationStep/page.mdx","depth":3},{"type":"step","name":"deleteOrderChangesStep","description":"This step deletes order changes.","link":"../../../Steps_Order/functions/core_flows.Order.Steps_Order.deleteOrderChangesStep/page.mdx","depth":4},{"type":"step","name":"deleteOrderShippingMethods","description":"This step deletes order shipping methods.","link":"../../../Steps_Order/functions/core_flows.Order.Steps_Order.deleteOrderShippingMethods/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":"CancelBeginOrderEditWorkflowInput","type":"[CancelBeginOrderEditWorkflowInput](../../../../types/core_flows.CancelBeginOrderEditWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"The data to cancel a requested order edit.","expandable":false,"children":[{"name":"order_id","type":"`string`","description":"The ID of the order to cancel the edit for.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="cancelBeginOrderEditWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`order-edit.canceled`
</Table.Cell>
<Table.Cell>
Emitted when an order edit request is canceled.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
order_id, // The ID of the order
actions, // The actions to edit the order
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -25,7 +25,7 @@ allows you to update custom data models linked to the fulfillment.
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around canceling a fulfillment.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/cancel-order-fulfillment.ts#L295" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/cancel-order-fulfillment.ts#L295" />
## Examples
@@ -164,6 +164,63 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### orderFulfillmentCanceled
This hook is executed after the fulfillment is canceled. You can consume this hook to perform custom actions on the canceled fulfillment.
#### Example
```ts
import { cancelOrderFulfillmentWorkflow } from "@medusajs/medusa/core-flows"
cancelOrderFulfillmentWorkflow.hooks.orderFulfillmentCanceled(
(async ({ fulfillment, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"fulfillment","type":"[FulfillmentDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentDTO/page.mdx)","description":"The fulfillment details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"The associated location's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"packed_at","type":"`null` \\| `Date`","description":"The date the fulfillment was packed.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipped_at","type":"`null` \\| `Date`","description":"The date the fulfillment was shipped.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"delivered_at","type":"`null` \\| `Date`","description":"The date the fulfillment was delivered.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"canceled_at","type":"`null` \\| `Date`","description":"The date the fulfillment was canceled.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`null` \\| `Record<string, unknown>`","description":"The data necessary for the fulfillment provider to process\nthe fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The associated fulfillment provider's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option_id","type":"`null` \\| `string`","description":"The associated shipping option's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option","type":"`null` \\| [ShippingOptionDTO](../../../../../fulfillment/interfaces/fulfillment.ShippingOptionDTO/page.mdx)","description":"The associated shipping option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Flag to indidcate whether shipping is required","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider","type":"[FulfillmentProviderDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentProviderDTO/page.mdx)","description":"The associated fulfillment provider.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"delivery_address","type":"[FulfillmentAddressDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentAddressDTO/page.mdx)","description":"The associated fulfillment address used for delivery.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[FulfillmentItemDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentItemDTO/page.mdx)[]","description":"The items of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"labels","type":"[FulfillmentLabelDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentLabelDTO/page.mdx)[]","description":"The labels of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The creation date of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"marked_shipped_by","type":"`null` \\| `string`","description":"The id of the user that marked fulfillment as shipped","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"The id of the user that created the fulfillment","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="orderFulfillmentCanceled"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Order.Workflows_Order/page.mdx#__type-1)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"fulfillment","type":"[FulfillmentDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentDTO/page.mdx)","description":"The fulfillment details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"The associated location's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"packed_at","type":"`null` \\| `Date`","description":"The date the fulfillment was packed.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipped_at","type":"`null` \\| `Date`","description":"The date the fulfillment was shipped.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"delivered_at","type":"`null` \\| `Date`","description":"The date the fulfillment was delivered.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"canceled_at","type":"`null` \\| `Date`","description":"The date the fulfillment was canceled.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`null` \\| `Record<string, unknown>`","description":"The data necessary for the fulfillment provider to process\nthe fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The associated fulfillment provider's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option_id","type":"`null` \\| `string`","description":"The associated shipping option's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option","type":"`null` \\| [ShippingOptionDTO](../../../../../fulfillment/interfaces/fulfillment.ShippingOptionDTO/page.mdx)","description":"The associated shipping option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Flag to indidcate whether shipping is required","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider","type":"[FulfillmentProviderDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentProviderDTO/page.mdx)","description":"The associated fulfillment provider.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"delivery_address","type":"[FulfillmentAddressDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentAddressDTO/page.mdx)","description":"The associated fulfillment address used for delivery.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[FulfillmentItemDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentItemDTO/page.mdx)[]","description":"The items of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"labels","type":"[FulfillmentLabelDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentLabelDTO/page.mdx)[]","description":"The labels of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The creation date of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"marked_shipped_by","type":"`null` \\| `string`","description":"The id of the user that marked fulfillment as shipped","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"The id of the user that created the fulfillment","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-recorLine truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`order.fulfillment_canceled`
</Table.Cell>
<Table.Cell>
Emitted when an order's fulfillment is canceled.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
order_id, // The ID of the order
fulfillment_id, // The ID of the fulfillment
no_notification, // Whether to notify the customer
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -29,7 +29,7 @@ make changes to custom models linked to the order.
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around canceling an order.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/cancel-order.ts#L127" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/cancel-order.ts#L127" />
## Examples
@@ -152,6 +152,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### orderCanceled
This hook is executed after the order is canceled. You can consume this hook to perform custom actions on the canceled order.
#### Example
```ts
import { cancelOrderWorkflow } from "@medusajs/medusa/core-flows"
cancelOrderWorkflow.hooks.orderCanceled(
(async ({ order }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"order","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="orderCanceled"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Order.Workflows_Order/page.mdx#__type-2)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"order","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="orderCanceled"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`order.canceled`
</Table.Cell>
<Table.Cell>
Emitted when an order is canceld.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
id, // The ID of the order
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -21,7 +21,7 @@ allows you to update custom data models linked to the orders.
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around order completion.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/complete-orders.ts#L49" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/complete-orders.ts#L49" />
## Examples
@@ -160,6 +160,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### ordersCompleted
This hook is executed after the orders are completed. You can consume this hook to perform custom actions on the completed orders.
#### Example
```ts
import { completeOrderWorkflow } from "@medusajs/medusa/core-flows"
completeOrderWorkflow.hooks.ordersCompleted(
(async ({ orders, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"orders","type":"[OrderDTO](../../../../../fulfillment/interfaces/fulfillment.OrderDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"version","type":"`number`","description":"The version of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The order's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[OrderStatus](../../../../../fulfillment/types/fulfillment.OrderStatus/page.mdx)","description":"The status of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the order was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the order was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The subtotal of the order. (Excluding taxes)","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The discount subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The discount total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The discount tax total of tLine truncated
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Order.Workflows_Order/page.mdx#__type-4)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"orders","type":"[OrderDTO](../../../../../fulfillment/interfaces/fulfillment.OrderDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"version","type":"`number`","description":"The version of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The order's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[OrderStatus](../../../../../fulfillment/types/fulfillment.OrderStatus/page.mdx)","description":"The status of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the order was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the order was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The subtotal of the order. (Excluding taxes)","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The discount subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The discount total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_tax_total","type":"[BigNumberValue](../../../../../fulfillmenLine truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`order.completed`
</Table.Cell>
<Table.Cell>
Emitted when orders are completed.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the order
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -26,7 +26,7 @@ This workflow confirms a requested claim. It's used by the
You can use this workflow within your customizations or your own custom workflows, allowing you to confirm a claim
for an order in your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/claim/confirm-claim-request.ts#L291" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/claim/confirm-claim-request.ts#L291" />
## Examples
@@ -144,3 +144,43 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"OrderPreviewDTO","type":"[OrderPreviewDTO](../../../../../order/interfaces/order.OrderPreviewDTO/page.mdx)","optional":false,"defaultValue":"","description":"The details of an order after a change is applied on it.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"version","type":"`number`","description":"The version of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The order's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[OrderStatus](../../../../../order/types/order.OrderStatus/page.mdx)","description":"The status of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the order was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the order was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"original_item_subtotal","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"original_item_tax_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"item_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"item_subtotal","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../.Line truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`order.claim_created`
</Table.Cell>
<Table.Cell>
Emitted when a claim is created for an order.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
order_id, // The ID of the order
claim_id, // The ID of the claim
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -26,7 +26,7 @@ This workflow confirms an exchange request. It's used by the
You can use this workflow within your customizations or your own custom workflows, allowing you to confirm an exchange
for an order in your custom flow.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/exchange/confirm-exchange-request.ts#L285" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/exchange/confirm-exchange-request.ts#L285" />
## Examples
@@ -144,3 +144,43 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"OrderPreviewDTO","type":"[OrderPreviewDTO](../../../../../order/interfaces/order.OrderPreviewDTO/page.mdx)","optional":false,"defaultValue":"","description":"The details of an order after a change is applied on it.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"version","type":"`number`","description":"The version of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The order's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[OrderStatus](../../../../../order/types/order.OrderStatus/page.mdx)","description":"The status of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the order was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the order was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"original_item_subtotal","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"original_item_tax_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"item_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"item_subtotal","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../.Line truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`order.exchange_created`
</Table.Cell>
<Table.Cell>
Emitted when an exchange is created for an order.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
order_id, // The ID of the order
exchange_id, // The ID of the exchange
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -7,6 +7,7 @@ tags:
- order
- inventory
- locking
- event bus
- workflow
- payment
- link
@@ -24,7 +25,7 @@ This workflow confirms an order edit request. It's used by the
You can use this workflow within your customizations or your own custom workflows, allowing you to confirm an order edit
in your custom flow.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/order-edit/confirm-order-edit-request.ts#L112" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/order-edit/confirm-order-edit-request.ts#L113" />
## Examples
@@ -133,7 +134,7 @@ const myWorkflow = createWorkflow(
## Steps
<WorkflowDiagram workflow={{"name":"confirmOrderEditRequestWorkflow","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":"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":"confirmOrderEditRequestValidationStep","description":"This step validates that a requested order edit can be confirmed.\nIf the order is canceled or the order change is not active, the step will throw an error.\n\n:::note\n\nYou can retrieve an order and order change 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":"../core_flows.Order.Workflows_Order.confirmOrderEditRequestValidationStep/page.mdx","depth":3},{"type":"step","name":"previewOrderChangeStep","description":"This step retrieves a preview of an order change.","link":"../../../Steps_Order/functions/core_flows.Order.Steps_Order.previewOrderChangeStep/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":"deleteReservationsByLineItemsStep","description":"This step deletes reservations by their associated line items.","link":"../../../../Reservation/Steps_Reservation/functions/core_flows.Reservation.Steps_Reservation.deleteReservationsByLineItemsStep/page.mdx","depth":6},{"type":"step","name":"reserveInventoryStep","description":"This step reserves the quantity of line items from the associated\nvariant's inventory.","link":"../../../../Cart/Steps_Cart/functions/core_flows.Cart.Steps_Cart.reserveInventoryStep/page.mdx","depth":7},{"type":"workflow","name":"createOrUpdateOrderPaymentCollectionWorkflow","description":"Create or update payment collection for an order.","link":"../core_flows.Order.Workflows_Order.createOrUpdateOrderPaymentCollectionWorkflow/page.mdx","depth":8}]}} />
<WorkflowDiagram workflow={{"name":"confirmOrderEditRequestWorkflow","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":"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":"confirmOrderEditRequestValidationStep","description":"This step validates that a requested order edit can be confirmed.\nIf the order is canceled or the order change is not active, the step will throw an error.\n\n:::note\n\nYou can retrieve an order and order change 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":"../core_flows.Order.Workflows_Order.confirmOrderEditRequestValidationStep/page.mdx","depth":3},{"type":"step","name":"previewOrderChangeStep","description":"This step retrieves a preview of an order change.","link":"../../../Steps_Order/functions/core_flows.Order.Steps_Order.previewOrderChangeStep/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":"deleteReservationsByLineItemsStep","description":"This step deletes reservations by their associated line items.","link":"../../../../Reservation/Steps_Reservation/functions/core_flows.Reservation.Steps_Reservation.deleteReservationsByLineItemsStep/page.mdx","depth":6},{"type":"step","name":"reserveInventoryStep","description":"This step reserves the quantity of line items from the associated\nvariant's inventory.","link":"../../../../Cart/Steps_Cart/functions/core_flows.Cart.Steps_Cart.reserveInventoryStep/page.mdx","depth":7},{"type":"workflow","name":"createOrUpdateOrderPaymentCollectionWorkflow","description":"Create or update payment collection for an order.","link":"../core_flows.Order.Workflows_Order.createOrUpdateOrderPaymentCollectionWorkflow/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":9}]}} />
## Input
@@ -142,3 +143,43 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"OrderPreviewDTO","type":"[OrderPreviewDTO](../../../../../order/interfaces/order.OrderPreviewDTO/page.mdx)","optional":false,"defaultValue":"","description":"The details of an order after a change is applied on it.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"version","type":"`number`","description":"The version of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The order's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[OrderStatus](../../../../../order/types/order.OrderStatus/page.mdx)","description":"The status of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the order was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the order was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"original_item_subtotal","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"original_item_tax_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"item_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"item_subtotal","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../.Line truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`order-edit.confirmed`
</Table.Cell>
<Table.Cell>
Emitted when an order edit request is confirmed.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
order_id, // The ID of the order
actions, // The actions to edit the order
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -23,7 +23,7 @@ This workflow confirms a return receival request. It's used by the
You can use this workflow within your customizations or your own custom workflows, allowing you
to confirm a return receival in your custom flow.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/return/confirm-receive-return-request.ts#L201" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/return/confirm-receive-return-request.ts#L201" />
## Examples
@@ -141,3 +141,43 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"OrderPreviewDTO","type":"[OrderPreviewDTO](../../../../../order/interfaces/order.OrderPreviewDTO/page.mdx)","optional":false,"defaultValue":"","description":"The details of an order after a change is applied on it.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"version","type":"`number`","description":"The version of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The order's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[OrderStatus](../../../../../order/types/order.OrderStatus/page.mdx)","description":"The status of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the order was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the order was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"original_item_subtotal","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"original_item_tax_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"item_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"item_subtotal","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../.Line truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`order.return_received`
</Table.Cell>
<Table.Cell>
Emitted when a return is marked as received.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
order_id, // The ID of the order
return_id, // The ID of the return
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -24,7 +24,7 @@ This workflow confirms a return request. It's used by the
You can use this workflow within your customizations or your own custom workflows, allowing you to confirm a return request
in your custom flow.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/return/confirm-return-request.ts#L239" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/return/confirm-return-request.ts#L239" />
## Examples
@@ -142,3 +142,43 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"OrderPreviewDTO","type":"[OrderPreviewDTO](../../../../../order/interfaces/order.OrderPreviewDTO/page.mdx)","optional":false,"defaultValue":"","description":"The details of an order after a change is applied on it.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"version","type":"`number`","description":"The version of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The order's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[OrderStatus](../../../../../order/types/order.OrderStatus/page.mdx)","description":"The status of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the order was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the order was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"original_item_subtotal","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"original_item_tax_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"item_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"item_subtotal","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../.Line truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`order.return_requested`
</Table.Cell>
<Table.Cell>
Emitted when a return request is confirmed.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
order_id, // The ID of the order
return_id, // The ID of the return
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -24,7 +24,7 @@ process it from the dashboard. This workflow is used by the
You can use this workflow within your customizations or your own custom workflows, allowing you to create a return
for an order in your custom flow.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/return/create-complete-return.ts#L350" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/return/create-complete-return.ts#L350" />
## Examples
@@ -167,6 +167,111 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### setPricingContext
This hook is executed before the return's shipping method is created. You can consume this hook to return any custom context useful for the prices retrieval of the shipping method's option.
For example, assuming you have the following custom pricing rule:
```json
{
"attribute": "location_id",
"operator": "eq",
"value": "sloc_123",
}
```
You can consume the `setPricingContext` hook to add the `location_id` context to the prices calculation:
```ts
import { createAndCompleteReturnOrderWorkflow } from "@medusajs/medusa/core-flows";
import { StepResponse } from "@medusajs/workflows-sdk";
createAndCompleteReturnOrderWorkflow.hooks.setPricingContext((
{ order, additional_data }, { container }
) => {
return new StepResponse({
location_id: "sloc_123", // Special price for in-store purchases
});
});
```
The price of the shipping method's option will now be retrieved using the context you return.
:::note
Learn more about prices calculation context in the [Prices Calculation](https://docs.medusajs.com/resources/commerce-modules/pricing/price-calculation) documentation.
:::
#### Example
```ts
import { createAndCompleteReturnOrderWorkflow } from "@medusajs/medusa/core-flows"
createAndCompleteReturnOrderWorkflow.hooks.setPricingContext(
(async ({ order, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"order","type":"[OrderDTO](../../../../../fulfillment/interfaces/fulfillment.OrderDTO/page.mdx)","description":"The order details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"version","type":"`number`","description":"The version of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The order's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[OrderStatus](../../../../../fulfillment/types/fulfillment.OrderStatus/page.mdx)","description":"The status of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the order was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the order was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The subtotal of the order. (Excluding taxes)","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The discount subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The discount total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The discountLine truncated
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Order.Workflows_Order/page.mdx#__type-14)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"order","type":"[OrderDTO](../../../../../fulfillment/interfaces/fulfillment.OrderDTO/page.mdx)","description":"The order details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"version","type":"`number`","description":"The version of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The order's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[OrderStatus](../../../../../fulfillment/types/fulfillment.OrderStatus/page.mdx)","description":"The status of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the order was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the order was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The subtotal of the order. (Excluding taxes)","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The discount subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The discount total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_tax_total","type":"[BigNumberValue](../../../Line truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`order.return_requested`
</Table.Cell>
<Table.Cell>
Emitted when a return request is confirmed.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
order_id, // The ID of the order
return_id, // The ID of the return
}
```
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`order.return_received`
</Table.Cell>
<Table.Cell>
Emitted when a return is marked as received.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
order_id, // The ID of the order
return_id, // The ID of the return
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -21,7 +21,7 @@ This workflow creates a shipping method for an order edit. It's used by the
You can use this workflow within your customizations or your own custom workflows, allowing you to create a shipping method
for an order edit in your in your own custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/order-edit/create-order-edit-shipping-method.ts#L152" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/order-edit/create-order-edit-shipping-method.ts#L152" />
## Examples
@@ -152,6 +152,55 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### setPricingContext
This hook is executed before the shipping method is created. You can consume this hook to return any custom context useful for the prices retrieval of the shipping method's option.
For example, assuming you have the following custom pricing rule:
```json
{
"attribute": "location_id",
"operator": "eq",
"value": "sloc_123",
}
```
You can consume the `setPricingContext` hook to add the `location_id` context to the prices calculation:
```ts
import { createOrderEditShippingMethodWorkflow } from "@medusajs/medusa/core-flows";
import { StepResponse } from "@medusajs/workflows-sdk";
createOrderEditShippingMethodWorkflow.hooks.setPricingContext((
{ order, shipping_option_id, additional_data }, { container }
) => {
return new StepResponse({
location_id: "sloc_123", // Special price for in-store purchases
});
});
```
The price of the shipping method's option will now be retrieved using the context you return.
:::note
Learn more about prices calculation context in the [Prices Calculation](https://docs.medusajs.com/resources/commerce-modules/pricing/price-calculation) documentation.
:::
#### Example
```ts
import { createOrderEditShippingMethodWorkflow } from "@medusajs/medusa/core-flows"
createOrderEditShippingMethodWorkflow.hooks.setPricingContext(
(async ({ order, shipping_option_id, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"order","type":"[OrderDTO](../../../../../fulfillment/interfaces/fulfillment.OrderDTO/page.mdx)","description":"The order details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"version","type":"`number`","description":"The version of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The order's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[OrderStatus](../../../../../fulfillment/types/fulfillment.OrderStatus/page.mdx)","description":"The status of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the order was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the order was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The subtotal of the order. (Excluding taxes)","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The discount subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The discount total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The discountLine truncated
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Order.Workflows_Order/page.mdx#__type-12)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"order","type":"[OrderDTO](../../../../../fulfillment/interfaces/fulfillment.OrderDTO/page.mdx)","description":"The order details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"version","type":"`number`","description":"The version of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The order's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[OrderStatus](../../../../../fulfillment/types/fulfillment.OrderStatus/page.mdx)","description":"The status of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the order was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the order was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The subtotal of the order. (Excluding taxes)","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The discount subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The discount total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_tax_total","type":"[BigNumberValue](../../../Line truncated
@@ -26,7 +26,7 @@ allows you to create custom data models linked to the fulfillment.
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around creating a fulfillment.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/create-fulfillment.ts#L392" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/create-fulfillment.ts#L392" />
## Examples
@@ -181,6 +181,63 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### fulfillmentCreated
This hook is executed after the fulfillment is created. You can consume this hook to perform custom actions on the created fulfillment.
#### Example
```ts
import { createOrderFulfillmentWorkflow } from "@medusajs/medusa/core-flows"
createOrderFulfillmentWorkflow.hooks.fulfillmentCreated(
(async ({ fulfillment, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"fulfillment","type":"[FulfillmentDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentDTO/page.mdx)","description":"The fulfillment details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"The associated location's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"packed_at","type":"`null` \\| `Date`","description":"The date the fulfillment was packed.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipped_at","type":"`null` \\| `Date`","description":"The date the fulfillment was shipped.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"delivered_at","type":"`null` \\| `Date`","description":"The date the fulfillment was delivered.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"canceled_at","type":"`null` \\| `Date`","description":"The date the fulfillment was canceled.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`null` \\| `Record<string, unknown>`","description":"The data necessary for the fulfillment provider to process\nthe fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The associated fulfillment provider's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option_id","type":"`null` \\| `string`","description":"The associated shipping option's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option","type":"`null` \\| [ShippingOptionDTO](../../../../../fulfillment/interfaces/fulfillment.ShippingOptionDTO/page.mdx)","description":"The associated shipping option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Flag to indidcate whether shipping is required","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider","type":"[FulfillmentProviderDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentProviderDTO/page.mdx)","description":"The associated fulfillment provider.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"delivery_address","type":"[FulfillmentAddressDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentAddressDTO/page.mdx)","description":"The associated fulfillment address used for delivery.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[FulfillmentItemDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentItemDTO/page.mdx)[]","description":"The items of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"labels","type":"[FulfillmentLabelDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentLabelDTO/page.mdx)[]","description":"The labels of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The creation date of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"marked_shipped_by","type":"`null` \\| `string`","description":"The id of the user that marked fulfillment as shipped","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"The id of the user that created the fulfillment","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="fulfillmentCreated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Order.Workflows_Order/page.mdx#__type-5)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"fulfillment","type":"[FulfillmentDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentDTO/page.mdx)","description":"The fulfillment details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"The associated location's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"packed_at","type":"`null` \\| `Date`","description":"The date the fulfillment was packed.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipped_at","type":"`null` \\| `Date`","description":"The date the fulfillment was shipped.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"delivered_at","type":"`null` \\| `Date`","description":"The date the fulfillment was delivered.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"canceled_at","type":"`null` \\| `Date`","description":"The date the fulfillment was canceled.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`null` \\| `Record<string, unknown>`","description":"The data necessary for the fulfillment provider to process\nthe fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The associated fulfillment provider's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option_id","type":"`null` \\| `string`","description":"The associated shipping option's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option","type":"`null` \\| [ShippingOptionDTO](../../../../../fulfillment/interfaces/fulfillment.ShippingOptionDTO/page.mdx)","description":"The associated shipping option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Flag to indidcate whether shipping is required","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider","type":"[FulfillmentProviderDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentProviderDTO/page.mdx)","description":"The associated fulfillment provider.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"delivery_address","type":"[FulfillmentAddressDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentAddressDTO/page.mdx)","description":"The associated fulfillment address used for delivery.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[FulfillmentItemDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentItemDTO/page.mdx)[]","description":"The items of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"labels","type":"[FulfillmentLabelDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentLabelDTO/page.mdx)[]","description":"The labels of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The creation date of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"marked_shipped_by","type":"`null` \\| `string`","description":"The id of the user that marked fulfillment as shipped","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"The id of the user that created the fulfillment","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-recorLine truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`order.fulfillment_created`
</Table.Cell>
<Table.Cell>
Emitted when a fulfillment is created for an order.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
order_id, // The ID of the order
fulfillment_id, // The ID of the fulfillment
no_notification, // Whether to notify the customer
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -18,12 +18,12 @@ This documentation provides a reference to the `createOrderShipmentWorkflow`. It
This workflow creates a shipment for an order. It's used by the [Create Order Shipment Admin API Route](https://docs.medusajs.com/api/admin#orders\_postordersidfulfillmentsfulfillment\_idshipments).
This workflow has a hook that allows you to perform custom actions on the created shipment. For example, you can pass under `additional_data` custom data that
This workflow has a hook that allows you to perform custom actions on the created shipment. For example, you can pass under `additional_data` custom data that
allows you to create custom data models linked to the shipment.
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around creating a shipment.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/create-shipment.ts#L155" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/create-shipment.ts#L198" />
## Examples
@@ -164,7 +164,7 @@ const myWorkflow = createWorkflow(
## Steps
<WorkflowDiagram workflow={{"name":"createOrderShipmentWorkflow","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":"createShipmentValidateOrder","description":"This step validates that a shipment can be created for an order. If the order is cancelled,\nthe items don't exist in the order, or the fulfillment doesn't exist in the order, \nthe step will throw an error.\n\n:::note\n\nYou can retrieve an order's 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":"../core_flows.Order.Workflows_Order.createShipmentValidateOrder/page.mdx","depth":2},{"type":"workflow","name":"createShipmentWorkflow","description":"Create a shipment for a fulfillment.","link":"../../../../Fulfillment/Workflows_Fulfillment/functions/core_flows.Fulfillment.Workflows_Fulfillment.createShipmentWorkflow/page.mdx","depth":3},{"type":"step","name":"registerOrderShipmentStep","description":"This step registers a shipment for an order.","link":"../../../Steps_Order/functions/core_flows.Order.Steps_Order.registerOrderShipmentStep/page.mdx","depth":3},{"type":"step","name":"emitEventStep","description":"Emit an event.","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":4},{"type":"hook","name":"shipmentCreated","description":"This hook is executed after the shipment is created. You can consume this hook to perform custom actions on the created shipment.","link":"#shipmentCreated","depth":5}]}} />
<WorkflowDiagram workflow={{"name":"createOrderShipmentWorkflow","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":"createShipmentValidateOrder","description":"This step validates that a shipment can be created for an order. If the order is cancelled,\nthe items don't exist in the order, or the fulfillment doesn't exist in the order,\nthe step will throw an error.\n\n:::note\n\nYou can retrieve an order's 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":"../core_flows.Order.Workflows_Order.createShipmentValidateOrder/page.mdx","depth":2},{"type":"workflow","name":"createShipmentWorkflow","description":"Create a shipment for a fulfillment.","link":"../../../../Fulfillment/Workflows_Fulfillment/functions/core_flows.Fulfillment.Workflows_Fulfillment.createShipmentWorkflow/page.mdx","depth":3},{"type":"step","name":"registerOrderShipmentStep","description":"This step registers a shipment for an order.","link":"../../../Steps_Order/functions/core_flows.Order.Steps_Order.registerOrderShipmentStep/page.mdx","depth":3},{"type":"step","name":"emitEventStep","description":"Emit an event.","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":4},{"type":"hook","name":"shipmentCreated","description":"This hook is executed after the shipment is created. You can consume this hook to perform custom actions on the created shipment.","link":"#shipmentCreated","depth":5}]}} />
## Input
@@ -178,6 +178,62 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### shipmentCreated
This hook is executed after the shipment is created. You can consume this hook to perform custom actions on the created shipment.
#### Example
```ts
import { createOrderShipmentWorkflow } from "@medusajs/medusa/core-flows"
createOrderShipmentWorkflow.hooks.shipmentCreated(
(async ({ shipment, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"shipment","type":"[FulfillmentDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentDTO/page.mdx)","description":"The fulfillment details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"The associated location's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"packed_at","type":"`null` \\| `Date`","description":"The date the fulfillment was packed.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipped_at","type":"`null` \\| `Date`","description":"The date the fulfillment was shipped.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"delivered_at","type":"`null` \\| `Date`","description":"The date the fulfillment was delivered.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"canceled_at","type":"`null` \\| `Date`","description":"The date the fulfillment was canceled.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`null` \\| `Record<string, unknown>`","description":"The data necessary for the fulfillment provider to process\nthe fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The associated fulfillment provider's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option_id","type":"`null` \\| `string`","description":"The associated shipping option's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option","type":"`null` \\| [ShippingOptionDTO](../../../../../fulfillment/interfaces/fulfillment.ShippingOptionDTO/page.mdx)","description":"The associated shipping option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Flag to indidcate whether shipping is required","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider","type":"[FulfillmentProviderDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentProviderDTO/page.mdx)","description":"The associated fulfillment provider.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"delivery_address","type":"[FulfillmentAddressDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentAddressDTO/page.mdx)","description":"The associated fulfillment address used for delivery.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[FulfillmentItemDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentItemDTO/page.mdx)[]","description":"The items of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"labels","type":"[FulfillmentLabelDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentLabelDTO/page.mdx)[]","description":"The labels of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The creation date of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"marked_shipped_by","type":"`null` \\| `string`","description":"The id of the user that marked fulfillment as shipped","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"The id of the user that created the fulfillment","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="shipmentCreated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Order.Workflows_Order/page.mdx#__type-10)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"shipment","type":"[FulfillmentDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentDTO/page.mdx)","description":"The fulfillment details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"The associated location's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"packed_at","type":"`null` \\| `Date`","description":"The date the fulfillment was packed.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipped_at","type":"`null` \\| `Date`","description":"The date the fulfillment was shipped.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"delivered_at","type":"`null` \\| `Date`","description":"The date the fulfillment was delivered.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"canceled_at","type":"`null` \\| `Date`","description":"The date the fulfillment was canceled.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`null` \\| `Record<string, unknown>`","description":"The data necessary for the fulfillment provider to process\nthe fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The associated fulfillment provider's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option_id","type":"`null` \\| `string`","description":"The associated shipping option's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option","type":"`null` \\| [ShippingOptionDTO](../../../../../fulfillment/interfaces/fulfillment.ShippingOptionDTO/page.mdx)","description":"The associated shipping option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Flag to indidcate whether shipping is required","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider","type":"[FulfillmentProviderDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentProviderDTO/page.mdx)","description":"The associated fulfillment provider.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"delivery_address","type":"[FulfillmentAddressDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentAddressDTO/page.mdx)","description":"The associated fulfillment address used for delivery.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[FulfillmentItemDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentItemDTO/page.mdx)[]","description":"The items of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"labels","type":"[FulfillmentLabelDTO](../../../../../fulfillment/interfaces/fulfillment.FulfillmentLabelDTO/page.mdx)[]","description":"The labels of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The creation date of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"marked_shipped_by","type":"`null` \\| `string`","description":"The id of the user that marked fulfillment as shipped","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"The id of the user that created the fulfillment","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-recordsLine truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`shipment.created`
</Table.Cell>
<Table.Cell>
Emitted when a shipment is created for an order.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
id, // the ID of the shipment
no_notification, // whether to notify the customer
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -22,7 +22,7 @@ This workflow marks a fulfillment in an order as delivered. It's used by the
You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around
marking a fulfillment as delivered.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/mark-order-fulfillment-as-delivered.ts#L165" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/mark-order-fulfillment-as-delivered.ts#L214" />
## Examples
@@ -140,3 +140,42 @@ const myWorkflow = createWorkflow(
## Input
<TypeList types={[{"name":"MarkOrderFulfillmentAsDeliveredWorkflowInput","type":"[MarkOrderFulfillmentAsDeliveredWorkflowInput](../../../../types/core_flows.MarkOrderFulfillmentAsDeliveredWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"The details to mark a fulfillment in an order as delivered.","expandable":false,"children":[{"name":"orderId","type":"`string`","description":"The ID of the order to mark the fulfillment as delivered in.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillmentId","type":"`string`","description":"The ID of the fulfillment to mark as delivered.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="markOrderFulfillmentAsDeliveredWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`delivery.created`
</Table.Cell>
<Table.Cell>
Emitted when a fulfillment is marked as delivered.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
id, // the ID of the fulfillment
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -5,6 +5,7 @@ sidebar_description: Request an order edit.
tags:
- remote query
- order
- event bus
- workflow
---
@@ -20,7 +21,7 @@ the [Request Order Edit Admin API Route](https://docs.medusajs.com/api/admin#ord
You can use this workflow within your customizations or your own custom workflows, allowing you to request an order edit
in your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/order-edit/request-order-edit.ts#L122" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/order-edit/request-order-edit.ts#L125" />
## Examples
@@ -129,7 +130,7 @@ const myWorkflow = createWorkflow(
## Steps
<WorkflowDiagram workflow={{"name":"requestOrderEditRequestWorkflow","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":"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":"requestOrderEditRequestValidationStep","description":"This step validates that a order edit can be requested.\nIf the order is canceled or the order change is not active, the step will throw an error.\n\n:::note\n\nYou can retrieve an order and order change 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":"../core_flows.Order.Workflows_Order.requestOrderEditRequestValidationStep/page.mdx","depth":3},{"type":"step","name":"updateOrderChangesStep","description":"This step updates order change.","link":"../../../Steps_Order/functions/core_flows.Order.Steps_Order.updateOrderChangesStep/page.mdx","depth":4},{"type":"step","name":"previewOrderChangeStep","description":"This step retrieves a preview of an order change.","link":"../../../Steps_Order/functions/core_flows.Order.Steps_Order.previewOrderChangeStep/page.mdx","depth":5}]}} />
<WorkflowDiagram workflow={{"name":"requestOrderEditRequestWorkflow","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":"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":"requestOrderEditRequestValidationStep","description":"This step validates that a order edit can be requested.\nIf the order is canceled or the order change is not active, the step will throw an error.\n\n:::note\n\nYou can retrieve an order and order change 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":"../core_flows.Order.Workflows_Order.requestOrderEditRequestValidationStep/page.mdx","depth":3},{"type":"step","name":"updateOrderChangesStep","description":"This step updates order change.","link":"../../../Steps_Order/functions/core_flows.Order.Steps_Order.updateOrderChangesStep/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":5},{"type":"step","name":"previewOrderChangeStep","description":"This step retrieves a preview of an order change.","link":"../../../Steps_Order/functions/core_flows.Order.Steps_Order.previewOrderChangeStep/page.mdx","depth":6}]}} />
## Input
@@ -138,3 +139,43 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"OrderPreviewDTO","type":"[OrderPreviewDTO](../../../../../order/interfaces/order.OrderPreviewDTO/page.mdx)","optional":false,"defaultValue":"","description":"The details of an order after a change is applied on it.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"version","type":"`number`","description":"The version of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The order's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[OrderStatus](../../../../../order/types/order.OrderStatus/page.mdx)","description":"The status of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the order was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the order was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"original_item_subtotal","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"original_item_tax_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"item_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"item_subtotal","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../.Line truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`order-edit.requested`
</Table.Cell>
<Table.Cell>
Emitted when an order edit is requested.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
order_id, // The ID of the order
actions, // The actions to edit the order
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -23,7 +23,7 @@ and the [Request Order Transfer Admin API Route](https://docs.medusajs.com/api/a
You can use this workflow within your customizations or your own custom workflows, allowing you to build a custom flow around requesting an order transfer.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/transfer/request-order-transfer.ts#L110" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/transfer/request-order-transfer.ts#L110" />
## Examples
@@ -149,3 +149,44 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"OrderPreviewDTO","type":"[OrderPreviewDTO](../../../../../order/interfaces/order.OrderPreviewDTO/page.mdx)","optional":false,"defaultValue":"","description":"The details of an order after a change is applied on it.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"version","type":"`number`","description":"The version of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The order's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[OrderStatus](../../../../../order/types/order.OrderStatus/page.mdx)","description":"The status of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the order was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the order was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"original_item_subtotal","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"original_item_tax_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"item_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"item_subtotal","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../.Line truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`order.transfer_requested`
</Table.Cell>
<Table.Cell>
Emitted when an order is requested to be transferred to
another customer.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
id, // The ID of the order
order_change_id, // The ID of the order change created for the transfer
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -21,7 +21,7 @@ and the [Update Outbound Shipping Admin API Route](https://docs.medusajs.com/api
You can use this workflow within your customizations or your own custom workflows, allowing you to update a claim's shipping method
in your own custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/claim/update-claim-shipping-method.ts#L169" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/claim/update-claim-shipping-method.ts#L169" />
## Examples
@@ -164,6 +164,55 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### setPricingContext
This hook is executed before the shipping method is updated. You can consume this hook to return any custom context useful for the prices retrieval of the shipping method's option.
For example, assuming you have the following custom pricing rule:
```json
{
"attribute": "location_id",
"operator": "eq",
"value": "sloc_123",
}
```
You can consume the `setPricingContext` hook to add the `location_id` context to the prices calculation:
```ts
import { updateClaimShippingMethodWorkflow } from "@medusajs/medusa/core-flows";
import { StepResponse } from "@medusajs/workflows-sdk";
updateClaimShippingMethodWorkflow.hooks.setPricingContext((
{ order_claim, order_change, additional_data }, { container }
) => {
return new StepResponse({
location_id: "sloc_123", // Special price for in-store purchases
});
});
```
The price of the shipping method's option will now be retrieved using the context you return.
:::note
Learn more about prices calculation context in the [Prices Calculation](https://docs.medusajs.com/resources/commerce-modules/pricing/price-calculation) documentation.
:::
#### Example
```ts
import { updateClaimShippingMethodWorkflow } from "@medusajs/medusa/core-flows"
updateClaimShippingMethodWorkflow.hooks.setPricingContext(
(async ({ order_claim, order_change, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"order_claim","type":"[OrderClaimDTO](../../../../../fulfillment/interfaces/fulfillment.OrderClaimDTO/page.mdx)","description":"The claim details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The claim's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[OrderClaimType](../../../../../fulfillment/types/fulfillment.OrderClaimType/page.mdx)","description":"The claim's type.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"order_id","type":"`string`","description":"The ID of the associated order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"order_version","type":"`number`","description":"The version of the order when the claim is applied.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The claim's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"claim_items","type":"`any`[]","description":"The items to be received from the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"additional_items","type":"`any`[]","description":"The items to be sent to the customer\nif the claim's type is `replace`.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"[OrderDTO](../../../../../fulfillment/interfaces/fulfillment.OrderDTO/page.mdx)","description":"The associated order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"return","type":"[ReturnDTO](../../../../../fulfillment/interfaces/fulfillment.ReturnDTO/page.mdx)","description":"The associated return, if the claim's type is `replace`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"return_id","type":"`string`","description":"The ID of the associated return, if the claim's type is `replace`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"no_notification","type":"`boolean`","description":"Whether the customer should receive notifications related\nto updates on the claim.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"refund_amount","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The refund amount of the claim.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_refund_amount","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The raw refund amount of the claim.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"The id of the user that created the order claim","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_methods","type":"[OrderShippingMethodDTO](../../../../../fulfillment/interfaces/fulfillment.OrderShippingMethodDTO/page.mdx)[]","description":"The shipping methods used to send the additional items.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"transactions","type":"[OrderTransactionDTO](../../../../../fulfillment/interfaces/fulfillment.OrderTransactionDTO/page.mdx)[]","description":"The claim's transactions if additional payment is required.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The creation date of the claim.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The update date of the claim.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"The deletion date of the claim.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"canceled_at","type":"`string` \\| `Date`","description":"The cancelation date of the claim.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"order_change","type":"[OrderChangeDTO](../../../../../fulfillment/interfaces/fulfillment.OrderChangeDTO/page.mdx)","description":"The order change details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order change","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"version","type":"`number`","description":"The version of the order change","optional":false,"defaultValue":"","expanLine truncated
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Order.Workflows_Order/page.mdx#__type-3)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"order_claim","type":"[OrderClaimDTO](../../../../../fulfillment/interfaces/fulfillment.OrderClaimDTO/page.mdx)","description":"The claim details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The claim's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[OrderClaimType](../../../../../fulfillment/types/fulfillment.OrderClaimType/page.mdx)","description":"The claim's type.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"order_id","type":"`string`","description":"The ID of the associated order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"order_version","type":"`number`","description":"The version of the order when the claim is applied.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The claim's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"claim_items","type":"`any`[]","description":"The items to be received from the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"additional_items","type":"`any`[]","description":"The items to be sent to the customer\nif the claim's type is `replace`.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"[OrderDTO](../../../../../fulfillment/interfaces/fulfillment.OrderDTO/page.mdx)","description":"The associated order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"return","type":"[ReturnDTO](../../../../../fulfillment/interfaces/fulfillment.ReturnDTO/page.mdx)","description":"The associated return, if the claim's type is `replace`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"return_id","type":"`string`","description":"The ID of the associated return, if the claim's type is `replace`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"no_notification","type":"`boolean`","description":"Whether the customer should receive notifications related\nto updates on the claim.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"refund_amount","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The refund amount of the claim.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_refund_amount","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The raw refund amount of the claim.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"The id of the user that created the order claim","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_methods","type":"[OrderShippingMethodDTO](../../../../../fulfillment/interfaces/fulfillment.OrderShippingMethodDTO/page.mdx)[]","description":"The shipping methods used to send the additional items.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"transactions","type":"[OrderTransactionDTO](../../../../../fulfillment/interfaces/fulfillment.OrderTransactionDTO/page.mdx)[]","description":"The claim's transactions if additional payment is required.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The creation date of the claim.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The update date of the claim.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"The deletion date of the claim.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"canceled_at","type":"`string` \\| `Date`","description":"The cancelation date of the claim.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"order_change","type":"[OrderChangeDTO](../../../../../fulfillment/interfaces/fulfillment.OrderChangeDTO/page.mdx)","description":"The order change details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order change","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"version","type":"`number`","Line truncated
@@ -21,7 +21,7 @@ or the [Outbound Inbound Shipping Admin API Route](https://docs.medusajs.com/api
You can use this workflow within your customizations or your own custom workflows, allowing you to update an exchange's
inbound or outbound shipping method in your custom flow.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/exchange/update-exchange-shipping-method.ts#L173" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/exchange/update-exchange-shipping-method.ts#L173" />
## Examples
@@ -164,6 +164,56 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### setPricingContext
This hook is executed before the shipping method is updated. You can consume this hook to return any custom context useful for the prices retrieval of the shipping method's option.
For example, assuming you have the following custom pricing rule:
```json
{
"attribute": "location_id",
"operator": "eq",
"value": "sloc_123",
}
```
You can consume the `setPricingContext` hook to add the `location_id` context to the prices calculation:
```ts
import { updateExchangeShippingMethodWorkflow } from "@medusajs/medusa/core-flows";
import { StepResponse } from "@medusajs/workflows-sdk";
updateExchangeShippingMethodWorkflow.hooks.setPricingContext((
{ order_exchange, order_change, additional_data }, { container }
) => {
return new StepResponse({
location_id: "sloc_123", // Special price for in-store purchases
});
});
```
The price of the shipping method's option will now be retrieved using the context you return.
:::note
Learn more about prices calculation context in the [Prices Calculation](https://docs.medusajs.com/resources/commerce-modules/pricing/price-calculation) documentation.
:::
#### Example
```ts
import { updateExchangeShippingMethodWorkflow } from "@medusajs/medusa/core-flows"
updateExchangeShippingMethodWorkflow.hooks.setPricingContext(
(async ({ order_exchange, order_change,
additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"order_exchange","type":"[OrderExchangeDTO](../../../../../fulfillment/interfaces/fulfillment.OrderExchangeDTO/page.mdx)","description":"The exchange details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The exchange's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"order_id","type":"`string`","description":"The associated order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"order_version","type":"`number`","description":"The version of the order when the exchange is applied.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The exchange's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"additional_items","type":"`any`[]","description":"The items to be sent to the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"[OrderDTO](../../../../../fulfillment/interfaces/fulfillment.OrderDTO/page.mdx)","description":"The associated order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"no_notification","type":"`boolean`","description":"Whether the customer should receive notifications related\nto updates on the exchange.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"difference_due","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The difference due of the order exchange.\n\n- If less than `0`, the merchant owes the customer this amount.\n- If greater than `0`, the customer owes the merchange this amount.\n- If equal to `0`, no payment is required by either sides.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_difference_due","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The raw difference due of the order exchange.\n\n- If less than `0`, the merchant owes the customer this amount.\n- If greater than `0`, the customer owes the merchange this amount.\n- If equal to `0`, no payment is required by either sides.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"allow_backorder","type":"`boolean`","description":"Whether the variants that are out of stock can be added to the exchange.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"return","type":"[ReturnDTO](../../../../../fulfillment/interfaces/fulfillment.ReturnDTO/page.mdx)","description":"The associated return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"return_id","type":"`string`","description":"The associated return's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"The id of the user that created the order exchange","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_methods","type":"[OrderShippingMethodDTO](../../../../../fulfillment/interfaces/fulfillment.OrderShippingMethodDTO/page.mdx)[]","description":"The shipping methods used to send the additional items.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"transactions","type":"[OrderTransactionDTO](../../../../../fulfillment/interfaces/fulfillment.OrderTransactionDTO/page.mdx)[]","description":"The exchange's transactions if additional payment is required.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The creation date of the exchange.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The update date of the exchange.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"The deletion date of the exchange.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"canceled_at","type":"`string` \\| `Date`","description":"The cancelation date of the exchange.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"order_change","type":"[OrderChangeDTO](../../../../../fulfillment/interfaces/fulfillment.OrderChangeDTO/page.mdx)","description":"The order change details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order change","optional":false,"defaultValueLine truncated
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Order.Workflows_Order/page.mdx#__type-11)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"order_exchange","type":"[OrderExchangeDTO](../../../../../fulfillment/interfaces/fulfillment.OrderExchangeDTO/page.mdx)","description":"The exchange details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The exchange's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"order_id","type":"`string`","description":"The associated order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"order_version","type":"`number`","description":"The version of the order when the exchange is applied.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The exchange's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"additional_items","type":"`any`[]","description":"The items to be sent to the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"[OrderDTO](../../../../../fulfillment/interfaces/fulfillment.OrderDTO/page.mdx)","description":"The associated order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"no_notification","type":"`boolean`","description":"Whether the customer should receive notifications related\nto updates on the exchange.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"difference_due","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The difference due of the order exchange.\n\n- If less than `0`, the merchant owes the customer this amount.\n- If greater than `0`, the customer owes the merchange this amount.\n- If equal to `0`, no payment is required by either sides.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_difference_due","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The raw difference due of the order exchange.\n\n- If less than `0`, the merchant owes the customer this amount.\n- If greater than `0`, the customer owes the merchange this amount.\n- If equal to `0`, no payment is required by either sides.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"allow_backorder","type":"`boolean`","description":"Whether the variants that are out of stock can be added to the exchange.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"return","type":"[ReturnDTO](../../../../../fulfillment/interfaces/fulfillment.ReturnDTO/page.mdx)","description":"The associated return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"return_id","type":"`string`","description":"The associated return's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"The id of the user that created the order exchange","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_methods","type":"[OrderShippingMethodDTO](../../../../../fulfillment/interfaces/fulfillment.OrderShippingMethodDTO/page.mdx)[]","description":"The shipping methods used to send the additional items.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"transactions","type":"[OrderTransactionDTO](../../../../../fulfillment/interfaces/fulfillment.OrderTransactionDTO/page.mdx)[]","description":"The exchange's transactions if additional payment is required.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The creation date of the exchange.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The update date of the exchange.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"The deletion date of the exchange.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"canceled_at","type":"`string` \\| `Date`","description":"The cancelation date of the exchange.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"order_change","type":"[OrderChangeDTO](../../../../../fulfillment/interfaces/fulfillment.OrderChangeDTO/page.mdx)","description":"The order change details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","tLine truncated
@@ -20,7 +20,7 @@ This workflow updates an order edit's shipping method. It's used by the
You can use this workflow within your customizations or your own custom workflows, allowing you to update an order edit's shipping method
in your custom flow.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/order-edit/update-order-edit-shipping-method.ts#L158" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/order-edit/update-order-edit-shipping-method.ts#L158" />
## Examples
@@ -163,6 +163,55 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### setPricingContext
This hook is executed before the shipping method's option is retrieved. You can consume this hook to return any custom context useful for the prices retrieval of shipping method's option.
For example, assuming you have the following custom pricing rule:
```json
{
"attribute": "location_id",
"operator": "eq",
"value": "sloc_123",
}
```
You can consume the `setPricingContext` hook to add the `location_id` context to the prices calculation:
```ts
import { updateOrderEditShippingMethodWorkflow } from "@medusajs/medusa/core-flows";
import { StepResponse } from "@medusajs/workflows-sdk";
updateOrderEditShippingMethodWorkflow.hooks.setPricingContext((
{ order, order_change, additional_data }, { container }
) => {
return new StepResponse({
location_id: "sloc_123", // Special price for in-store purchases
});
});
```
The price of the shipping method's option will now be retrieved using the context you return.
:::note
Learn more about prices calculation context in the [Prices Calculation](https://docs.medusajs.com/resources/commerce-modules/pricing/price-calculation) documentation.
:::
#### Example
```ts
import { updateOrderEditShippingMethodWorkflow } from "@medusajs/medusa/core-flows"
updateOrderEditShippingMethodWorkflow.hooks.setPricingContext(
(async ({ order, order_change, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"order","type":"[OrderDTO](../../../../../fulfillment/interfaces/fulfillment.OrderDTO/page.mdx)","description":"The order details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"version","type":"`number`","description":"The version of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The order's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[OrderStatus](../../../../../fulfillment/types/fulfillment.OrderStatus/page.mdx)","description":"The status of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the order was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the order was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The subtotal of the order. (Excluding taxes)","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The discount subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The discount total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The discountLine truncated
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Order.Workflows_Order/page.mdx#__type-13)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"order","type":"[OrderDTO](../../../../../fulfillment/interfaces/fulfillment.OrderDTO/page.mdx)","description":"The order details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"version","type":"`number`","description":"The version of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The order's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[OrderStatus](../../../../../fulfillment/types/fulfillment.OrderStatus/page.mdx)","description":"The status of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the order was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the order was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The original tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The subtotal of the order. (Excluding taxes)","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_subtotal","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The discount subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_total","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The discount total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_tax_total","type":"[BigNumberValue](../../../Line truncated
@@ -21,7 +21,7 @@ This workflow updates an order's general details, such as its email or addresses
You can use this workflow within your customizations or your own custom workflows, allowing you to update an
order's details in your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/update-order.ts#L120" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/update-order.ts#L120" />
## Examples
@@ -147,3 +147,43 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"OrderPreviewDTO","type":"[OrderPreviewDTO](../../../../../order/interfaces/order.OrderPreviewDTO/page.mdx)","optional":false,"defaultValue":"","description":"The details of an order after a change is applied on it.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"version","type":"`number`","description":"The version of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The order's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[OrderStatus](../../../../../order/types/order.OrderStatus/page.mdx)","description":"The status of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency of the order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the order was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the order was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"original_item_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"original_item_subtotal","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"original_item_tax_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The original item tax total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"item_total","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The item total of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../../../../order/types/order.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":"item_subtotal","type":"[BigNumberValue](../../../../../order/types/order.BigNumberValue/page.mdx)","description":"The item subtotal of the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"numeric","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"[BigNumberRawValue](../../.Line truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`order.updated`
</Table.Cell>
<Table.Cell>
Emitted when the details of an order or draft order is updated. This
doesn't include updates made by an edit.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
id, // The ID of the order
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -20,7 +20,7 @@ This workflow updates the shipping method of a return. It's used by the
You can use this workflow within your customizations or your own custom workflows, allowing you
to update the shipping method of a return in your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/workflows/return/update-return-shipping-method.ts#L169" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/workflows/return/update-return-shipping-method.ts#L169" />
## Examples
@@ -163,6 +163,55 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### setPricingContext
This hook is executed before the shipping method is created. You can consume this hook to return any custom context useful for the prices retrieval of the shipping method's option.
For example, assuming you have the following custom pricing rule:
```json
{
"attribute": "location_id",
"operator": "eq",
"value": "sloc_123",
}
```
You can consume the `setPricingContext` hook to add the `location_id` context to the prices calculation:
```ts
import { updateReturnShippingMethodWorkflow } from "@medusajs/medusa/core-flows";
import { StepResponse } from "@medusajs/workflows-sdk";
updateReturnShippingMethodWorkflow.hooks.setPricingContext((
{ order_return, order_change, additional_data }, { container }
) => {
return new StepResponse({
location_id: "sloc_123", // Special price for in-store purchases
});
});
```
The price of the shipping method's option will now be retrieved using the context you return.
:::note
Learn more about prices calculation context in the [Prices Calculation](https://docs.medusajs.com/resources/commerce-modules/pricing/price-calculation) documentation.
:::
#### Example
```ts
import { updateReturnShippingMethodWorkflow } from "@medusajs/medusa/core-flows"
updateReturnShippingMethodWorkflow.hooks.setPricingContext(
(async ({ order_return, order_change, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"order_return","type":"[ReturnDTO](../../../../../fulfillment/interfaces/fulfillment.ReturnDTO/page.mdx)","description":"The return details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the return.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ReturnStatus](../../../../../fulfillment/types/fulfillment.ReturnStatus/page.mdx)","description":"The status of the return.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"order_id","type":"`string`","description":"The associated order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[OrderReturnItemDTO](../../../../../fulfillment/interfaces/fulfillment.OrderReturnItemDTO/page.mdx)[]","description":"The items of the return","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The return's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"refund_amount","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The refund amount of the return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_refund_amount","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The raw refund amount of the return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"[OrderDTO](../../../../../fulfillment/interfaces/fulfillment.OrderDTO/page.mdx)","description":"The associated order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"exchange_id","type":"`string`","description":"The associated exchange's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"exchange","type":"[OrderExchangeDTO](../../../../../fulfillment/interfaces/fulfillment.OrderExchangeDTO/page.mdx)","description":"The associated exchange.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"claim_id","type":"`string`","description":"The associated claim's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"claim","type":"[OrderClaimDTO](../../../../../fulfillment/interfaces/fulfillment.OrderClaimDTO/page.mdx)","description":"The associated claim.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"The ID of the location to return the items to.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"no_notification","type":"`boolean`","description":"Whether the customer should receive notifications related\nto updates on the return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"The id of the user that created the return","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_methods","type":"[OrderShippingMethodDTO](../../../../../fulfillment/interfaces/fulfillment.OrderShippingMethodDTO/page.mdx)[]","description":"The shipping methods used to receive the returned items.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"transactions","type":"[OrderTransactionDTO](../../../../../fulfillment/interfaces/fulfillment.OrderTransactionDTO/page.mdx)[]","description":"The return's transactions if refund is required.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The creation date of the return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The update date of the return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"The deletion date of the return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"canceled_at","type":"`string` \\| `Date`","description":"The cancelation date of the return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"requested_at","type":"`string` \\| `Date`","description":"The request date of the return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"received_at","type":"`string` \\| `Date`","description":"The receival date of the return.","optional":true,"defaultValue":"","expandable":false,"children"Line truncated
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Order.Workflows_Order/page.mdx#__type-15)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"order_return","type":"[ReturnDTO](../../../../../fulfillment/interfaces/fulfillment.ReturnDTO/page.mdx)","description":"The return details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the return.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ReturnStatus](../../../../../fulfillment/types/fulfillment.ReturnStatus/page.mdx)","description":"The status of the return.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"order_id","type":"`string`","description":"The associated order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[OrderReturnItemDTO](../../../../../fulfillment/interfaces/fulfillment.OrderReturnItemDTO/page.mdx)[]","description":"The items of the return","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`number`","description":"The return's display ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"refund_amount","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The refund amount of the return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_refund_amount","type":"[BigNumberValue](../../../../../fulfillment/types/fulfillment.BigNumberValue/page.mdx)","description":"The raw refund amount of the return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"[OrderDTO](../../../../../fulfillment/interfaces/fulfillment.OrderDTO/page.mdx)","description":"The associated order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"exchange_id","type":"`string`","description":"The associated exchange's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"exchange","type":"[OrderExchangeDTO](../../../../../fulfillment/interfaces/fulfillment.OrderExchangeDTO/page.mdx)","description":"The associated exchange.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"claim_id","type":"`string`","description":"The associated claim's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"claim","type":"[OrderClaimDTO](../../../../../fulfillment/interfaces/fulfillment.OrderClaimDTO/page.mdx)","description":"The associated claim.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"The ID of the location to return the items to.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"no_notification","type":"`boolean`","description":"Whether the customer should receive notifications related\nto updates on the return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"The id of the user that created the return","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_methods","type":"[OrderShippingMethodDTO](../../../../../fulfillment/interfaces/fulfillment.OrderShippingMethodDTO/page.mdx)[]","description":"The shipping methods used to receive the returned items.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"transactions","type":"[OrderTransactionDTO](../../../../../fulfillment/interfaces/fulfillment.OrderTransactionDTO/page.mdx)[]","description":"The return's transactions if refund is required.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The creation date of the return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The update date of the return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"The deletion date of the return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"canceled_at","type":"`string` \\| `Date`","description":"The cancelation date of the return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"requested_at","type":"`string` \\| `Date`","description":"The request date of the return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"received_at","type":"`string` \\| `Date`","description":"The receLine truncated
@@ -8,7 +8,7 @@ by other workflows, such as createClaimShippingMethodWorkflow.
You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around fetching
shipping options for an order.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/order/utils/fetch-shipping-option.ts#L166" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/order/utils/fetch-shipping-option.ts#L166" />
## Examples
@@ -171,6 +171,55 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### setPricingContext
This hook is executed before the shipping option is fetched. You can consume this hook to set the pricing context for the shipping option. This is useful when you have custom pricing rules that depend on the context of the order.
For example, assuming you have the following custom pricing rule:
```json
{
"attribute": "location_id",
"operator": "eq",
"value": "sloc_123",
}
```
You can consume the `setPricingContext` hook to add the `location_id` context to the prices calculation:
```ts
import { fetchShippingOptionForOrderWorkflow } from "@medusajs/medusa/core-flows";
import { StepResponse } from "@medusajs/workflows-sdk";
fetchShippingOptionForOrderWorkflow.hooks.setPricingContext((
{ shipping_option_id, currency_code, order_id, context, additional_data }, { container }
) => {
return new StepResponse({
location_id: "sloc_123", // Special price for in-store purchases
});
});
```
The shipping option's price will now be retrieved using the context you return.
:::note
Learn more about prices calculation context in the [Prices Calculation](https://docs.medusajs.com/resources/commerce-modules/pricing/price-calculation) documentation.
:::
#### Example
```ts
import { fetchShippingOptionForOrderWorkflow } from "@medusajs/medusa/core-flows"
fetchShippingOptionForOrderWorkflow.hooks.setPricingContext(
(async ({}, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="setPricingContext"/>
<TypeList types={[{"name":"input","type":"`input`","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="setPricingContext"/>
@@ -10,6 +10,10 @@ tags:
- remote query
- order
- event bus
- link
- cart
- inventory
- locking
---
import { TypeList, WorkflowDiagram } from "docs-ui"
@@ -25,7 +29,7 @@ capture the payment, or authorize the payment session. It's used when a
You can use this workflow within your own customizations or custom workflows, allowing you
to process a payment in your custom flows based on a webhook action.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/payment/workflows/process-payment.ts#L39" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/payment/workflows/process-payment.ts#L39" />
## Examples
@@ -150,8 +154,48 @@ const myWorkflow = createWorkflow(
## Steps
<WorkflowDiagram workflow={{"name":"processPaymentWorkflow","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":"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":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":"{\n return (\n input.action === PaymentActions.SUCCESSFUL && !!paymentData.data.length\n )\n }","depth":"4","steps":[{"type":"workflow","name":"capturePaymentWorkflow","description":"Capture a payment.","link":"../core_flows.Payment.Workflows_Payment.capturePaymentWorkflow/page.mdx","depth":4}]},{"type":"when","condition":"{\n // Authorize payment session if no Cart is linked to the payment\n // When associated with a Cart, the complete cart workflow will handle the authorization\n return (\n !cartPaymentCollection.data.length &&\n input.action === PaymentActions.AUTHORIZED &&\n !!input.data?.session_id\n )\n }","depth":"5","steps":[{"type":"step","name":"authorizePaymentSessionStep","description":"This step authorizes a payment session.","link":"../../../Steps_Payment/functions/core_flows.Payment.Steps_Payment.authorizePaymentSessionStep/page.mdx","depth":5}]}]}} />
<WorkflowDiagram workflow={{"name":"processPaymentWorkflow","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":"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":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":"{\n return (\n input.action === PaymentActions.SUCCESSFUL && !!paymentData.data.length\n )\n }","depth":"4","steps":[{"type":"workflow","name":"capturePaymentWorkflow","description":"Capture a payment.","link":"../core_flows.Payment.Workflows_Payment.capturePaymentWorkflow/page.mdx","depth":4}]},{"type":"when","condition":"{\n // Authorize payment session if no Cart is linked to the payment\n // When associated with a Cart, the complete cart workflow will handle the authorization\n return (\n !cartPaymentCollection.data.length &&\n input.action === PaymentActions.AUTHORIZED &&\n !!input.data?.session_id\n )\n }","depth":"5","steps":[{"type":"step","name":"authorizePaymentSessionStep","description":"This step authorizes a payment session.","link":"../../../Steps_Payment/functions/core_flows.Payment.Steps_Payment.authorizePaymentSessionStep/page.mdx","depth":5}]},{"type":"when","condition":"{\n return !!cartPaymentCollection.data.length\n }","depth":"6","steps":[{"type":"workflow","name":"completeCartWorkflow","description":"Complete a cart and place an order.","link":"../../../../Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.completeCartWorkflow/page.mdx","depth":6}]}]}} />
## Input
<TypeList types={[{"name":"ProcessPaymentWorkflowInput","type":"`ProcessPaymentWorkflowInput`","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="processPaymentWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`order.placed`
</Table.Cell>
<Table.Cell>
Emitted when an order is placed, or when a draft order is converted to an
order.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
{
id, // The ID of the order
}
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -25,7 +25,7 @@ This workflow creates, updates, and deletes product variants. It's used by the
You can use this workflow within your own customizations or custom workflows to manage the variants of a product. You can also
use this within a [seed script](https://docs.medusajs.com/learn/fundamentals/custom-cli-scripts/seed-data) or in a custom import script.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/product/workflows/batch-product-variants.ts#L73" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/batch-product-variants.ts#L73" />
## Examples
@@ -203,3 +203,72 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"BatchProductVariantsWorkflowOutput","type":"[BatchProductVariantsWorkflowOutput](../../../../interfaces/core_flows.BatchProductVariantsWorkflowOutput/page.mdx)","optional":false,"defaultValue":"","description":"The result of managing the product variants.","expandable":false,"children":[{"name":"created","type":"[ProductVariantDTO](../../../../../product/interfaces/product.ProductVariantDTO/page.mdx)[]","description":"The records that were created in the bulk operation.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The tile of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`null` \\| `string`","description":"The SKU of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"barcode","type":"`null` \\| `string`","description":"The barcode of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"ean","type":"`null` \\| `string`","description":"The EAN of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"upc","type":"`null` \\| `string`","description":"The UPC of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"allow_backorder","type":"`boolean`","description":"Whether the product variant can be ordered when it's out of stock.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"manage_inventory","type":"`boolean`","description":"Whether the product variant's inventory should be managed by the core system.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Whether the product variant's requires shipping.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`null` \\| `string`","description":"The HS Code of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`null` \\| `string`","description":"The origin country of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`null` \\| `string`","description":"The MID Code of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`null` \\| `string`","description":"The material of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`null` \\| `number`","description":"The weight of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`null` \\| `number`","description":"The length of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`null` \\| `number`","description":"The height of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`null` \\| `number`","description":"The width of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"[ProductOptionValueDTO](../../../../../product/interfaces/product.ProductOptionValueDTO/page.mdx)[]","description":"The associated product options.","optional":false,"defaultValue":"","expandable":true,"children":[{"name":"id","type":"`string`","description":"The ID of the product option value.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string`","description":"The value of the product option value.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product option value was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product option value was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"option","type":"`null` \\| [ProductOptionDTO](../../../../../product/interfaces/product.ProductOptionDTO/page.mdx)","description":"The associated product option. It may only be available if the `option` relation is expanded.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"option_id","type":"`null` \\| `string`","description":"The associated product option id.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":Line truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-variant.updated`
</Table.Cell>
<Table.Cell>
Emitted when product variants are updated.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product variant
}]
```
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`product-variant.created`
</Table.Cell>
<Table.Cell>
Emitted when product variants are created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product variant
}]
```
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`product-variant.deleted`
</Table.Cell>
<Table.Cell>
Emitted when product variants are deleted.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product variant
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -18,7 +18,7 @@ This workflow creates, updates, or deletes products. It's used by the
You can use this workflow within your own customizations or custom workflows to manage products in bulk. This is
also useful when writing a [seed script](https://docs.medusajs.com/learn/fundamentals/custom-cli-scripts/seed-data) or a custom import script.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/product/workflows/batch-products.ts#L95" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/batch-products.ts#L95" />
## Examples
@@ -216,3 +216,87 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"BatchWorkflowOutput","type":"[BatchWorkflowOutput](../../../../../types/CommonTypes/types/types.CommonTypes.BatchWorkflowOutput/page.mdx)&#60;[ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)&#62;","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"The handle of the product. The handle can be used to create slug URL paths.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"The subttle of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"The description of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"Whether the product is a gift card.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../../../product/types/product.ProductStatus/page.mdx)","description":"The status of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"The URL of the product's thumbnail.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`null` \\| `number`","description":"The width of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`null` \\| `number`","description":"The weight of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`null` \\| `number`","description":"The length of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`null` \\| `number`","description":"The height of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`null` \\| `string`","description":"The origin country of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`null` \\| `string`","description":"The HS Code of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`null` \\| `string`","description":"The MID Code of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`null` \\| `string`","description":"The material of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"`null` \\| [ProductCollectionDTO](../../../../../product/interfaces/product.ProductCollectionDTO/page.mdx)","description":"The associated product collection.","optional":false,"defaultValue":"","expandable":true,"children":[{"name":"id","type":"`string`","description":"The ID of the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"The handle of the product collection. The handle can be used to create slug URL paths.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product collection was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product collection was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product collection was deleted.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"[ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)[]","description":"The associated products.","optional":true,"defaultValue":"","expandable":true,"children":[]}]},{"name":"collection_id","type":"`null` \\| `string`","description":"The associated product collection id.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`null` \\| [ProductTypeDTO](../../../../../product/interfaces/product.ProductTypeDTO/pagLine truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-variant.created`
</Table.Cell>
<Table.Cell>
Emitted when product variants are created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product variant
}]
```
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`product.updated`
</Table.Cell>
<Table.Cell>
Emitted when products are updated.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product
}]
```
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`product.created`
</Table.Cell>
<Table.Cell>
Emitted when products are created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product
}]
```
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`product.deleted`
</Table.Cell>
<Table.Cell>
Emitted when products are deleted.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -22,7 +22,7 @@ allows you to create custom data models linked to the product collections.
You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product-collection creation.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/product/workflows/create-collections.ts#L54" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/create-collections.ts#L54" />
## Examples
@@ -169,6 +169,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### collectionsCreated
This hook is executed after the collections are created. You can consume this hook to perform custom actions on the created collections.
#### Example
```ts
import { createCollectionsWorkflow } from "@medusajs/medusa/core-flows"
createCollectionsWorkflow.hooks.collectionsCreated(
(async ({ collections, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"collections","type":"[ProductCollectionDTO](../../../../../product/interfaces/product.ProductCollectionDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"The handle of the product collection. The handle can be used to create slug URL paths.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product collection was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product collection was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product collection was deleted.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"[ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)[]","description":"The associated products.","optional":true,"defaultValue":"","expandable":true,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="collectionsCreated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product.Workflows_Product/page.mdx#__type)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"collections","type":"[ProductCollectionDTO](../../../../../product/interfaces/product.ProductCollectionDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"The handle of the product collection. The handle can be used to create slug URL paths.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product collection was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product collection was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product collection was deleted.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"[ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)[]","description":"The associated products.","optional":true,"defaultValue":"","expandable":true,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="collectionsCreated"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-collection.created`
</Table.Cell>
<Table.Cell>
Emitted when product collections are created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product collection
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -21,7 +21,7 @@ allows you to create custom data models linked to the product options.
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around product-option creation.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/product/workflows/create-product-options.ts#L58" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/create-product-options.ts#L58" />
## Examples
@@ -192,6 +192,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### productOptionsCreated
This hook is executed after the product options are created. You can consume this hook to perform custom actions on the created product options.
#### Example
```ts
import { createProductOptionsWorkflow } from "@medusajs/medusa/core-flows"
createProductOptionsWorkflow.hooks.productOptionsCreated(
(async ({ product_options, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_options","type":"[ProductOptionDTO](../../../../../product/interfaces/product.ProductOptionDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the product option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"values","type":"[ProductOptionValueDTO](../../../../../product/interfaces/product.ProductOptionValueDTO/page.mdx)[]","description":"The associated product option values.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product option was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product option was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)","description":"The associated product.","optional":true,"defaultValue":"","expandable":true,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"The associated product id.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product option was deleted.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="productOptionsCreated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product.Workflows_Product/page.mdx#__type-1)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_options","type":"[ProductOptionDTO](../../../../../product/interfaces/product.ProductOptionDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the product option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"values","type":"[ProductOptionValueDTO](../../../../../product/interfaces/product.ProductOptionValueDTO/page.mdx)[]","description":"The associated product option values.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product option was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product option was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)","description":"The associated product.","optional":true,"defaultValue":"","expandable":true,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"The associated product id.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product option was deleted.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="productOptionsCreated"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-option.created`
</Table.Cell>
<Table.Cell>
Emitted when product options are created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product option
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -22,7 +22,7 @@ allows you to create custom data models linked to the product tags.
You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product-tag creation.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/product/workflows/create-product-tags.ts#L54" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/create-product-tags.ts#L54" />
## Examples
@@ -169,6 +169,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### productTagsCreated
This hook is executed after the product tags are created. You can consume this hook to perform custom actions on the created product tags.
#### Example
```ts
import { createProductTagsWorkflow } from "@medusajs/medusa/core-flows"
createProductTagsWorkflow.hooks.productTagsCreated(
(async ({ product_tags, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_tags","type":"[ProductTagDTO](../../../../../product/interfaces/product.ProductTagDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product tag.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string`","description":"The value of the product tag.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"[ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)[]","description":"The associated products.","optional":true,"defaultValue":"","expandable":true,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="productTagsCreated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product.Workflows_Product/page.mdx#__type-2)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_tags","type":"[ProductTagDTO](../../../../../product/interfaces/product.ProductTagDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product tag.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string`","description":"The value of the product tag.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"[ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)[]","description":"The associated products.","optional":true,"defaultValue":"","expandable":true,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="productTagsCreated"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-tag.created`
</Table.Cell>
<Table.Cell>
Emitted when product tags are created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product tag
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -22,7 +22,7 @@ allows you to create custom data models linked to the product types.
You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product-type creation.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/product/workflows/create-product-types.ts#L54" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/create-product-types.ts#L54" />
## Examples
@@ -169,6 +169,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### productTypesCreated
This hook is executed after the product types are created. You can consume this hook to perform custom actions on the created product types.
#### Example
```ts
import { createProductTypesWorkflow } from "@medusajs/medusa/core-flows"
createProductTypesWorkflow.hooks.productTypesCreated(
(async ({ product_types, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_types","type":"[ProductTypeDTO](../../../../../product/interfaces/product.ProductTypeDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product type.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string`","description":"The value of the product type.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product type was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product type was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product type was deleted.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="productTypesCreated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product.Workflows_Product/page.mdx#__type-3)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_types","type":"[ProductTypeDTO](../../../../../product/interfaces/product.ProductTypeDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product type.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string`","description":"The value of the product type.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product type was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product type was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product type was deleted.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="productTypesCreated"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-type.created`
</Table.Cell>
<Table.Cell>
Emitted when product types are created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product type
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -32,7 +32,7 @@ Learn more about adding rules to the product variant's prices in the Pricing Mod
:::
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/c1e6b81972cacebe040fd28dc5c6da82e60b3eac/packages/core/core-flows/src/product/workflows/create-product-variants.ts#L249" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/create-product-variants.ts#L249" />
## Examples
@@ -215,6 +215,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### productVariantsCreated
This hook is executed after the product variants are created. You can consume this hook to perform custom actions on the created product variants.
#### Example
```ts
import { createProductVariantsWorkflow } from "@medusajs/medusa/core-flows"
createProductVariantsWorkflow.hooks.productVariantsCreated(
(async ({ product_variants, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_variants","type":"`object`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"prices","type":"[MoneyAmountDTO](../../../../../pricing/interfaces/pricing.MoneyAmountDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"The ID of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The tile of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`null` \\| `string`","description":"The SKU of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"barcode","type":"`null` \\| `string`","description":"The barcode of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"ean","type":"`null` \\| `string`","description":"The EAN of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"upc","type":"`null` \\| `string`","description":"The UPC of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"allow_backorder","type":"`boolean`","description":"Whether the product variant can be ordered when it's out of stock.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"manage_inventory","type":"`boolean`","description":"Whether the product variant's inventory should be managed by the core system.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Whether the product variant's requires shipping.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`null` \\| `string`","description":"The HS Code of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`null` \\| `string`","description":"The origin country of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`null` \\| `string`","description":"The MID Code of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`null` \\| `string`","description":"The material of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`null` \\| `number`","description":"The weight of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`null` \\| `number`","description":"The length of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`null` \\| `number`","description":"The height of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`null` \\| `number`","description":"The width of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"[ProductOptionValueDTO](../../../../../product/interfaces/product.ProductOptionValueDTO/page.mdx)[]","description":"The associated product options.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"The associated product id.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product variant was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product variant was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product variant was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)","description":"The associated product.","optional":true,"defaultValue":"","expandable":true,"children":[]},{"name":"variant_rank","type":"`null` \\| `number`","description":"he ranking of the variant among other variants associated with the product.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional dataLine truncated
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product.Workflows_Product/page.mdx#__type-12)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_variants","type":"`object`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"prices","type":"[MoneyAmountDTO](../../../../../pricing/interfaces/pricing.MoneyAmountDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"The ID of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The tile of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`null` \\| `string`","description":"The SKU of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"barcode","type":"`null` \\| `string`","description":"The barcode of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"ean","type":"`null` \\| `string`","description":"The EAN of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"upc","type":"`null` \\| `string`","description":"The UPC of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"allow_backorder","type":"`boolean`","description":"Whether the product variant can be ordered when it's out of stock.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"manage_inventory","type":"`boolean`","description":"Whether the product variant's inventory should be managed by the core system.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Whether the product variant's requires shipping.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`null` \\| `string`","description":"The HS Code of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`null` \\| `string`","description":"The origin country of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`null` \\| `string`","description":"The MID Code of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`null` \\| `string`","description":"The material of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`null` \\| `number`","description":"The weight of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`null` \\| `number`","description":"The length of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`null` \\| `number`","description":"The height of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`null` \\| `number`","description":"The width of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"[ProductOptionValueDTO](../../../../../product/interfaces/product.ProductOptionValueDTO/page.mdx)[]","description":"The associated product options.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"The associated product id.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product variant was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product variant was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product variant was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)","description":"The associated product.","optional":true,"defaultValue":"","expandable":true,"children":[]},{"name":"variant_rank","type":"`null` \\| `number`","description":"he ranking of the variant among other variants associated with the product.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"aLine truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-variant.created`
</Table.Cell>
<Table.Cell>
Emitted when product variants are created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product variant
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -32,7 +32,7 @@ Learn more about adding rules to the product variant's prices in the Pricing Mod
:::
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/c1e6b81972cacebe040fd28dc5c6da82e60b3eac/packages/core/core-flows/src/product/workflows/create-products.ts#L163" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/create-products.ts#L163" />
## Examples
@@ -247,6 +247,76 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### productsCreated
This hook is executed after the products are created. You can consume this hook to perform custom actions on the created products.
#### Example
```ts
import { createProductsWorkflow } from "@medusajs/medusa/core-flows"
createProductsWorkflow.hooks.productsCreated(
(async ({ products, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"products","type":"[ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"The handle of the product. The handle can be used to create slug URL paths.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"The subttle of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"The description of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"Whether the product is a gift card.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../../../product/types/product.ProductStatus/page.mdx)","description":"The status of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"The URL of the product's thumbnail.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`null` \\| `number`","description":"The width of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`null` \\| `number`","description":"The weight of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`null` \\| `number`","description":"The length of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`null` \\| `number`","description":"The height of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`null` \\| `string`","description":"The origin country of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`null` \\| `string`","description":"The HS Code of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`null` \\| `string`","description":"The MID Code of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`null` \\| `string`","description":"The material of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"`null` \\| [ProductCollectionDTO](../../../../../product/interfaces/product.ProductCollectionDTO/page.mdx)","description":"The associated product collection.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"collection_id","type":"`null` \\| `string`","description":"The associated product collection id.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`null` \\| [ProductTypeDTO](../../../../../product/interfaces/product.ProductTypeDTO/page.mdx)","description":"The associated product type.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"type_id","type":"`null` \\| `string`","description":"The associated product type id.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"[ProductTagDTO](../../../../../product/interfaces/product.ProductTagDTO/page.mdx)[]","description":"The associated product tags.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"variants","type":"[ProductVariantDTO](../../../../../product/interfaces/product.ProductVariantDTO/page.mdx)[]","description":"The associated product variants.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"options","type":"[ProductOptionDTO](../../../../../product/interfaces/product.ProductOptionDTO/page.mdx)[]","description":"The associated product options.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"images","type":"[ProductImageDTO](../../../../../product/interfaces/product.ProductImageDTO/page.mdx)[]","description":"The associated product images.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"external_id","type":"`null` \\| `string`","description":"The ID of the product in an external system. This is useful if you're integrating the product with a third-party service and want to maintain\na reference to the ID in the integrated service.","optional":false,"defaulLine truncated
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product.Workflows_Product/page.mdx#__type-14)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"products","type":"[ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"The handle of the product. The handle can be used to create slug URL paths.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"The subttle of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"The description of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"Whether the product is a gift card.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../../../product/types/product.ProductStatus/page.mdx)","description":"The status of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"The URL of the product's thumbnail.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`null` \\| `number`","description":"The width of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`null` \\| `number`","description":"The weight of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`null` \\| `number`","description":"The length of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`null` \\| `number`","description":"The height of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`null` \\| `string`","description":"The origin country of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`null` \\| `string`","description":"The HS Code of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`null` \\| `string`","description":"The MID Code of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`null` \\| `string`","description":"The material of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"`null` \\| [ProductCollectionDTO](../../../../../product/interfaces/product.ProductCollectionDTO/page.mdx)","description":"The associated product collection.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"collection_id","type":"`null` \\| `string`","description":"The associated product collection id.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`null` \\| [ProductTypeDTO](../../../../../product/interfaces/product.ProductTypeDTO/page.mdx)","description":"The associated product type.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"type_id","type":"`null` \\| `string`","description":"The associated product type id.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"[ProductTagDTO](../../../../../product/interfaces/product.ProductTagDTO/page.mdx)[]","description":"The associated product tags.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"variants","type":"[ProductVariantDTO](../../../../../product/interfaces/product.ProductVariantDTO/page.mdx)[]","description":"The associated product variants.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"options","type":"[ProductOptionDTO](../../../../../product/interfaces/product.ProductOptionDTO/page.mdx)[]","description":"The associated product options.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"images","type":"[ProductImageDTO](../../../../../product/interfaces/product.ProductImageDTO/page.mdx)[]","description":"The associated product images.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"external_id","type":"`null` \\| `string`","description":"The ID of the product in an external system. This is useful if you're integrating the product with a third-party service andLine truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-variant.created`
</Table.Cell>
<Table.Cell>
Emitted when product variants are created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product variant
}]
```
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`product.created`
</Table.Cell>
<Table.Cell>
Emitted when products are created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -4,6 +4,7 @@ sidebar_label: deleteCollectionsWorkflow
sidebar_description: Delete one or more product collection.
tags:
- product
- link
- event bus
- workflow
---
@@ -14,15 +15,15 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
This documentation provides a reference to the `deleteCollectionsWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
This workflow deletes one or more product collections. It's used by the
This workflow deletes one or more product collections. It's used by the
[Delete Product Collection Admin API Route](https://docs.medusajs.com/api/admin#collections\_deletecollectionsid).
This workflow has a hook that allows you to perform custom actions after the product collections are deleted. For example,
This workflow has a hook that allows you to perform custom actions after the product collections are deleted. For example,
you can delete custom records linked to the product colleciton.
You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product-collection deletion.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/product/workflows/delete-collections.ts#L46" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/delete-collections.ts#L50" />
## Examples
@@ -131,7 +132,7 @@ const myWorkflow = createWorkflow(
## Steps
<WorkflowDiagram workflow={{"name":"deleteCollectionsWorkflow","steps":[{"type":"step","name":"deleteCollectionsStep","description":"This step deletes one or more collections.","link":"../../../Steps_Product/functions/core_flows.Product.Steps_Product.deleteCollectionsStep/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},{"type":"hook","name":"collectionsDeleted","description":"This hook is executed after the collections are deleted. You can consume this hook to perform custom actions on the deleted collections.","link":"#collectionsDeleted","depth":3}]}} />
<WorkflowDiagram workflow={{"name":"deleteCollectionsWorkflow","steps":[{"type":"step","name":"deleteCollectionsStep","description":"This step deletes one or more collections.","link":"../../../Steps_Product/functions/core_flows.Product.Steps_Product.deleteCollectionsStep/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},{"type":"step","name":"emitEventStep","description":"Emit an event.","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":2},{"type":"hook","name":"collectionsDeleted","description":"This hook is executed after the collections are deleted. You can consume this hook to perform custom actions on the deleted collections.","link":"#collectionsDeleted","depth":3}]}} />
## Input
@@ -145,6 +146,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### collectionsDeleted
This hook is executed after the collections are deleted. You can consume this hook to perform custom actions on the deleted collections.
#### Example
```ts
import { deleteCollectionsWorkflow } from "@medusajs/medusa/core-flows"
deleteCollectionsWorkflow.hooks.collectionsDeleted(
(async ({ ids }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","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="collectionsDeleted"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product.Workflows_Product/page.mdx#__type-15)","description":"The input data for the hook.","optional":false,"defaultValue":"","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="collectionsDeleted"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-collection.deleted`
</Table.Cell>
<Table.Cell>
Emitted when product collections are deleted.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product collection
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -4,6 +4,7 @@ sidebar_label: deleteProductOptionsWorkflow
sidebar_description: Delete one or more product option.
tags:
- product
- link
- event bus
- workflow
---
@@ -14,15 +15,15 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
This documentation provides a reference to the `deleteProductOptionsWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
This workflow deletes one or more product options. It's used by the
This workflow deletes one or more product options. It's used by the
[Delete Product Option Admin API Route](https://docs.medusajs.com/api/admin#products\_deleteproductsidoptionsoption\_id).
This workflow has a hook that allows you to perform custom actions after the product options are deleted. For example,
This workflow has a hook that allows you to perform custom actions after the product options are deleted. For example,
you can delete custom records linked to the product colleciton.
You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product-option deletion.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/product/workflows/delete-product-options.ts#L46" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/delete-product-options.ts#L48" />
## Examples
@@ -131,7 +132,7 @@ const myWorkflow = createWorkflow(
## Steps
<WorkflowDiagram workflow={{"name":"deleteProductOptionsWorkflow","steps":[{"type":"step","name":"deleteProductOptionsStep","description":"This step deletes one or more product options.","link":"../../../Steps_Product/functions/core_flows.Product.Steps_Product.deleteProductOptionsStep/page.mdx","depth":1},{"type":"hook","name":"productOptionsDeleted","description":"This hook is executed after the options are deleted. You can consume this hook to perform custom actions on the deleted options.","link":"#productOptionsDeleted","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}]}} />
<WorkflowDiagram workflow={{"name":"deleteProductOptionsWorkflow","steps":[{"type":"step","name":"deleteProductOptionsStep","description":"This step deletes one or more product options.","link":"../../../Steps_Product/functions/core_flows.Product.Steps_Product.deleteProductOptionsStep/page.mdx","depth":1},{"type":"hook","name":"productOptionsDeleted","description":"This hook is executed after the options are deleted. You can consume this hook to perform custom actions on the deleted options.","link":"#productOptionsDeleted","depth":2},{"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":3},{"type":"step","name":"emitEventStep","description":"Emit an event.","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":3}]}} />
## Input
@@ -145,6 +146,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### productOptionsDeleted
This hook is executed after the options are deleted. You can consume this hook to perform custom actions on the deleted options.
#### Example
```ts
import { deleteProductOptionsWorkflow } from "@medusajs/medusa/core-flows"
deleteProductOptionsWorkflow.hooks.productOptionsDeleted(
(async ({ ids }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","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="productOptionsDeleted"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product.Workflows_Product/page.mdx#__type-16)","description":"The input data for the hook.","optional":false,"defaultValue":"","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="productOptionsDeleted"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-option.deleted`
</Table.Cell>
<Table.Cell>
Emitted when product options are deleted.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product option
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -22,7 +22,7 @@ you can delete custom records linked to the product tags.
You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product-tag deletion.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/product/workflows/delete-product-tags.ts#L46" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/delete-product-tags.ts#L46" />
## Examples
@@ -145,6 +145,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### productTagsDeleted
This hook is executed after the tags are deleted. You can consume this hook to perform custom actions on the deleted tags.
#### Example
```ts
import { deleteProductTagsWorkflow } from "@medusajs/medusa/core-flows"
deleteProductTagsWorkflow.hooks.productTagsDeleted(
(async ({ ids }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","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="productTagsDeleted"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product.Workflows_Product/page.mdx#__type-18)","description":"The input data for the hook.","optional":false,"defaultValue":"","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="productTagsDeleted"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-tag.deleted`
</Table.Cell>
<Table.Cell>
Emitted when product tags are deleted.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product tag
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -4,6 +4,7 @@ sidebar_label: deleteProductTypesWorkflow
sidebar_description: Delete one or more product types.
tags:
- product
- link
- event bus
- workflow
---
@@ -14,15 +15,15 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
This documentation provides a reference to the `deleteProductTypesWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
This workflow deletes one or more product types. It's used by the
This workflow deletes one or more product types. It's used by the
[Delete Product Types Admin API Route](https://docs.medusajs.com/api/admin#product-types\_deleteproducttypesid).
This workflow has a hook that allows you to perform custom actions after the product types are deleted. For example,
This workflow has a hook that allows you to perform custom actions after the product types are deleted. For example,
you can delete custom records linked to the product types.
You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product-type deletion.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/product/workflows/delete-product-types.ts#L46" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/delete-product-types.ts#L48" />
## Examples
@@ -131,7 +132,7 @@ const myWorkflow = createWorkflow(
## Steps
<WorkflowDiagram workflow={{"name":"deleteProductTypesWorkflow","steps":[{"type":"step","name":"deleteProductTypesStep","description":"This step deletes one or more product types.","link":"../../../Steps_Product/functions/core_flows.Product.Steps_Product.deleteProductTypesStep/page.mdx","depth":1},{"type":"hook","name":"productTypesDeleted","description":"This hook is executed after the types are deleted. You can consume this hook to perform custom actions on the deleted types.","link":"#productTypesDeleted","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}]}} />
<WorkflowDiagram workflow={{"name":"deleteProductTypesWorkflow","steps":[{"type":"step","name":"deleteProductTypesStep","description":"This step deletes one or more product types.","link":"../../../Steps_Product/functions/core_flows.Product.Steps_Product.deleteProductTypesStep/page.mdx","depth":1},{"type":"hook","name":"productTypesDeleted","description":"This hook is executed after the types are deleted. You can consume this hook to perform custom actions on the deleted types.","link":"#productTypesDeleted","depth":2},{"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":3},{"type":"step","name":"emitEventStep","description":"Emit an event.","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":3}]}} />
## Input
@@ -145,6 +146,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### productTypesDeleted
This hook is executed after the types are deleted. You can consume this hook to perform custom actions on the deleted types.
#### Example
```ts
import { deleteProductTypesWorkflow } from "@medusajs/medusa/core-flows"
deleteProductTypesWorkflow.hooks.productTypesDeleted(
(async ({ ids }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","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="productTypesDeleted"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product.Workflows_Product/page.mdx#__type-17)","description":"The input data for the hook.","optional":false,"defaultValue":"","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="productTypesDeleted"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-type.deleted`
</Table.Cell>
<Table.Cell>
Emitted when product types are deleted.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product type
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -25,7 +25,7 @@ you can delete custom records linked to the product variants.
You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product-variant deletion.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/product/workflows/delete-product-variants.ts#L54" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/delete-product-variants.ts#L54" />
## Examples
@@ -148,6 +148,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### productVariantsDeleted
This hook is executed after the variants are deleted. You can consume this hook to perform custom actions on the deleted variants.
#### Example
```ts
import { deleteProductVariantsWorkflow } from "@medusajs/medusa/core-flows"
deleteProductVariantsWorkflow.hooks.productVariantsDeleted(
(async ({ ids }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","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="productVariantsDeleted"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product.Workflows_Product/page.mdx#__type-19)","description":"The input data for the hook.","optional":false,"defaultValue":"","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="productVariantsDeleted"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-variant.deleted`
</Table.Cell>
<Table.Cell>
Emitted when product variants are deleted.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product variant
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -17,15 +17,15 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
This documentation provides a reference to the `deleteProductsWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
This workflow deletes one or more products. It's used by the
This workflow deletes one or more products. It's used by the
[Delete Products Admin API Route](https://docs.medusajs.com/api/admin#products\_deleteproductsid).
This workflow has a hook that allows you to perform custom actions after the products are deleted. For example,
This workflow has a hook that allows you to perform custom actions after the products are deleted. For example,
you can delete custom records linked to the products.
You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product deletion.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/product/workflows/delete-products.ts#L53" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/delete-products.ts#L53" />
## Examples
@@ -148,6 +148,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### productsDeleted
This hook is executed after the products are deleted. You can consume this hook to perform custom actions on the deleted products.
#### Example
```ts
import { deleteProductsWorkflow } from "@medusajs/medusa/core-flows"
deleteProductsWorkflow.hooks.productsDeleted(
(async ({ ids }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","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="productsDeleted"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product.Workflows_Product/page.mdx#__type-20)","description":"The input data for the hook.","optional":false,"defaultValue":"","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="productsDeleted"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product.deleted`
</Table.Cell>
<Table.Cell>
Emitted when products are deleted.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -26,7 +26,7 @@ For example, you can import products from another system.
The workflow only starts the import, but you'll have to confirm it using the [Workflow Engine](https://docs.medusajs.com/resources/infrastructure-modules/workflow-engine).
The below example shows how to confirm the import.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/product/workflows/import-products.ts#L92" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/import-products.ts#L92" />
## Examples
@@ -195,7 +195,7 @@ This example API route uses the same implementation as the [Confirm Product Impo
## Steps
<WorkflowDiagram workflow={{"name":"importProductsWorkflow","steps":[{"type":"step","name":"parseProductCsvStep","description":"This step parses a CSV file holding products to import, returning the products as\nobjects that can be imported.","link":"../../../Steps_Product/functions/core_flows.Product.Steps_Product.parseProductCsvStep/page.mdx","depth":1},{"type":"step","name":"groupProductsForBatchStep","description":"This step groups products to be created or updated.","link":"../../../Steps_Product/functions/core_flows.Product.Steps_Product.groupProductsForBatchStep/page.mdx","depth":2},{"type":"step","name":"waitConfirmationProductImportStep","description":"This step waits until a product import is confirmed. It's useful before executing the\nbatchProductsWorkflow.\n\nThis step is asynchronous and will make the workflow using it a [Long-Running Workflow](https://docs.medusajs.com/learn/fundamentals/workflows/long-running-workflow).","link":"../../../Steps_Product/functions/core_flows.Product.Steps_Product.waitConfirmationProductImportStep/page.mdx","depth":3},{"type":"step","name":"notifyOnFailureStep","description":"This step sends one or more notification when a workflow fails. This\nstep can be used in the beginning of a workflow so that, when the workflow fails,\nthe step's compensation function is triggered to send the notification.","link":"../../../../Notification/Steps_Notification/functions/core_flows.Notification.Steps_Notification.notifyOnFailureStep/page.mdx","depth":4},{"type":"step","name":"sendNotificationsStep","description":"This step sends one or more notifications.","link":"../../../../Notification/Steps_Notification/functions/core_flows.Notification.Steps_Notification.sendNotificationsStep/page.mdx","depth":5}]}} />
<WorkflowDiagram workflow={{"name":"importProductsWorkflow","steps":[{"type":"step","name":"parseProductCsvStep","description":"This step parses a CSV file holding products to import, returning the products as\nobjects that can be imported.","link":"../../../Steps_Product/functions/core_flows.Product.Steps_Product.parseProductCsvStep/page.mdx","depth":1},{"type":"step","name":"groupProductsForBatchStep","description":"This step groups products to be created or updated.","link":"../../../Steps_Product/functions/core_flows.Product.Steps_Product.groupProductsForBatchStep/page.mdx","depth":2},{"type":"step","name":"waitConfirmationProductImportStep","description":"This step waits until a product import is confirmed. It's useful before executing the\nbatchProductsWorkflow.\n\nThis step is asynchronous and will make the workflow using it a [Long-Running Workflow](https://docs.medusajs.com/learn/fundamentals/workflows/long-running-workflow).","link":"../../../Steps_Product/functions/core_flows.Product.Steps_Product.waitConfirmationProductImportStep/page.mdx","depth":3},{"type":"step","name":"notifyOnFailureStep","description":"This step sends one or more notification when a workflow fails. This\nstep can be used in the beginning of a workflow so that, when the workflow fails,\nthe step's compensation function is triggered to send the notification.","link":"../../../../Notification/Steps_Notification/functions/core_flows.Notification.Steps_Notification.notifyOnFailureStep/page.mdx","depth":4},{"type":"workflow","name":"batchProductsWorkflow","description":"Manage products in bulk.","link":"../core_flows.Product.Workflows_Product.batchProductsWorkflow/page.mdx","depth":5},{"type":"step","name":"sendNotificationsStep","description":"This step sends one or more notifications.","link":"../../../../Notification/Steps_Notification/functions/core_flows.Notification.Steps_Notification.sendNotificationsStep/page.mdx","depth":6}]}} />
## Input
@@ -204,3 +204,87 @@ This example API route uses the same implementation as the [Confirm Product Impo
## Output
<TypeList types={[{"name":"ImportProductsSummary","type":"[ImportProductsSummary](../../../../../types/WorkflowTypes/ProductWorkflow/interfaces/types.WorkflowTypes.ProductWorkflow.ImportProductsSummary/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"toCreate","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"toUpdate","type":"`number`","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="importProductsWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-variant.created`
</Table.Cell>
<Table.Cell>
Emitted when product variants are created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product variant
}]
```
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`product.updated`
</Table.Cell>
<Table.Cell>
Emitted when products are updated.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product
}]
```
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`product.created`
</Table.Cell>
<Table.Cell>
Emitted when products are created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product
}]
```
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`product.deleted`
</Table.Cell>
<Table.Cell>
Emitted when products are deleted.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -22,7 +22,7 @@ allows you to update custom data models linked to the product collections.
You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product-collection update.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/product/workflows/update-collections.ts#L59" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/update-collections.ts#L59" />
## Examples
@@ -181,6 +181,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### collectionsUpdated
This hook is executed after the collections are updated. You can consume this hook to perform custom actions on the updated collections.
#### Example
```ts
import { updateCollectionsWorkflow } from "@medusajs/medusa/core-flows"
updateCollectionsWorkflow.hooks.collectionsUpdated(
(async ({ additional_data, collections }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collections","type":"[ProductCollectionDTO](../../../../../product/interfaces/product.ProductCollectionDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"The handle of the product collection. The handle can be used to create slug URL paths.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product collection was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product collection was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product collection was deleted.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"[ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)[]","description":"The associated products.","optional":true,"defaultValue":"","expandable":true,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="collectionsUpdated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product.Workflows_Product/page.mdx#__type-21)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collections","type":"[ProductCollectionDTO](../../../../../product/interfaces/product.ProductCollectionDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"The handle of the product collection. The handle can be used to create slug URL paths.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product collection was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product collection was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product collection was deleted.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"[ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)[]","description":"The associated products.","optional":true,"defaultValue":"","expandable":true,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="collectionsUpdated"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-collection.updated`
</Table.Cell>
<Table.Cell>
Emitted when product collections are updated.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product collection
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -21,7 +21,7 @@ allows you to update custom data models linked to the product options.
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around product-option update.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/product/workflows/update-product-options.ts#L58" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/update-product-options.ts#L58" />
## Examples
@@ -180,6 +180,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### productOptionsUpdated
This hook is executed after the product options are updated. You can consume this hook to perform custom actions on the updated product options.
#### Example
```ts
import { updateProductOptionsWorkflow } from "@medusajs/medusa/core-flows"
updateProductOptionsWorkflow.hooks.productOptionsUpdated(
(async ({ product_options, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_options","type":"[ProductOptionDTO](../../../../../product/interfaces/product.ProductOptionDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the product option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"values","type":"[ProductOptionValueDTO](../../../../../product/interfaces/product.ProductOptionValueDTO/page.mdx)[]","description":"The associated product option values.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product option was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product option was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)","description":"The associated product.","optional":true,"defaultValue":"","expandable":true,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"The associated product id.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product option was deleted.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="productOptionsUpdated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product.Workflows_Product/page.mdx#__type-22)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_options","type":"[ProductOptionDTO](../../../../../product/interfaces/product.ProductOptionDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the product option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"values","type":"[ProductOptionValueDTO](../../../../../product/interfaces/product.ProductOptionValueDTO/page.mdx)[]","description":"The associated product option values.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product option was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product option was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)","description":"The associated product.","optional":true,"defaultValue":"","expandable":true,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"The associated product id.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product option was deleted.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="productOptionsUpdated"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-option.updated`
</Table.Cell>
<Table.Cell>
Emitted when product options are updated.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product option
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -22,7 +22,7 @@ allows you to update custom data models linked to the product tags.
You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product-tag updates.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/product/workflows/update-product-tags.ts#L59" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/update-product-tags.ts#L59" />
## Examples
@@ -181,6 +181,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### productTagsUpdated
This hook is executed after the product tags are updated. You can consume this hook to perform custom actions on the updated product tags.
#### Example
```ts
import { updateProductTagsWorkflow } from "@medusajs/medusa/core-flows"
updateProductTagsWorkflow.hooks.productTagsUpdated(
(async ({ product_tags, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_tags","type":"[ProductTagDTO](../../../../../product/interfaces/product.ProductTagDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product tag.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string`","description":"The value of the product tag.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"[ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)[]","description":"The associated products.","optional":true,"defaultValue":"","expandable":true,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="productTagsUpdated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product.Workflows_Product/page.mdx#__type-24)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_tags","type":"[ProductTagDTO](../../../../../product/interfaces/product.ProductTagDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product tag.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string`","description":"The value of the product tag.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"[ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)[]","description":"The associated products.","optional":true,"defaultValue":"","expandable":true,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="productTagsUpdated"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-tag.updated`
</Table.Cell>
<Table.Cell>
Emitted when product tags are updated.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product tag
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -22,7 +22,7 @@ allows you to update custom data models linked to the product types.
You can also use this workflow within your own custom workflows, allowing you to wrap custom logic around product-type updates.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/product/workflows/update-product-types.ts#L59" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/update-product-types.ts#L59" />
## Examples
@@ -181,6 +181,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### productTypesUpdated
This hook is executed after the product types are updated. You can consume this hook to perform custom actions on the updated product types.
#### Example
```ts
import { updateProductTypesWorkflow } from "@medusajs/medusa/core-flows"
updateProductTypesWorkflow.hooks.productTypesUpdated(
(async ({ product_types, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_types","type":"[ProductTypeDTO](../../../../../product/interfaces/product.ProductTypeDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product type.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string`","description":"The value of the product type.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product type was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product type was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product type was deleted.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="productTypesUpdated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product.Workflows_Product/page.mdx#__type-23)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_types","type":"[ProductTypeDTO](../../../../../product/interfaces/product.ProductTypeDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product type.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string`","description":"The value of the product type.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product type was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product type was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"Holds custom data in key-value pairs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product type was deleted.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="productTypesUpdated"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-type.updated`
</Table.Cell>
<Table.Cell>
Emitted when product types are updated.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product type
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -29,7 +29,7 @@ Learn more about adding rules to the product variant's prices in the Pricing Mod
:::
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/c1e6b81972cacebe040fd28dc5c6da82e60b3eac/packages/core/core-flows/src/product/workflows/update-product-variants.ts#L127" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/update-product-variants.ts#L127" />
## Examples
@@ -363,6 +363,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### productVariantsUpdated
This hook is executed after the product variants are updated. You can consume this hook to perform custom actions on the updated product variants.
#### Example
```ts
import { updateProductVariantsWorkflow } from "@medusajs/medusa/core-flows"
updateProductVariantsWorkflow.hooks.productVariantsUpdated(
(async ({ product_variants, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_variants","type":"`object`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"price_set","type":"`undefined` \\| [PriceSetDTO](../../../../../pricing/interfaces/pricing.PriceSetDTO/page.mdx)","description":"","optional":false,"defaultValue":"priceSetForVariant","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"The ID of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The tile of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`null` \\| `string`","description":"The SKU of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"barcode","type":"`null` \\| `string`","description":"The barcode of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"ean","type":"`null` \\| `string`","description":"The EAN of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"upc","type":"`null` \\| `string`","description":"The UPC of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"allow_backorder","type":"`boolean`","description":"Whether the product variant can be ordered when it's out of stock.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"manage_inventory","type":"`boolean`","description":"Whether the product variant's inventory should be managed by the core system.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Whether the product variant's requires shipping.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`null` \\| `string`","description":"The HS Code of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`null` \\| `string`","description":"The origin country of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`null` \\| `string`","description":"The MID Code of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`null` \\| `string`","description":"The material of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`null` \\| `number`","description":"The weight of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`null` \\| `number`","description":"The length of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`null` \\| `number`","description":"The height of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`null` \\| `number`","description":"The width of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"[ProductOptionValueDTO](../../../../../product/interfaces/product.ProductOptionValueDTO/page.mdx)[]","description":"The associated product options.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"The associated product id.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product variant was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product variant was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product variant was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)","description":"The associated product.","optional":true,"defaultValue":"","expandable":true,"children":[]},{"name":"variant_rank","type":"`null` \\| `number`","description":"he ranking of the variant among other variants associated with the product.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","Line truncated
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product.Workflows_Product/page.mdx#__type-33)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_variants","type":"`object`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"price_set","type":"`undefined` \\| [PriceSetDTO](../../../../../pricing/interfaces/pricing.PriceSetDTO/page.mdx)","description":"","optional":false,"defaultValue":"priceSetForVariant","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"The ID of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The tile of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`null` \\| `string`","description":"The SKU of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"barcode","type":"`null` \\| `string`","description":"The barcode of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"ean","type":"`null` \\| `string`","description":"The EAN of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"upc","type":"`null` \\| `string`","description":"The UPC of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"allow_backorder","type":"`boolean`","description":"Whether the product variant can be ordered when it's out of stock.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"manage_inventory","type":"`boolean`","description":"Whether the product variant's inventory should be managed by the core system.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Whether the product variant's requires shipping.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`null` \\| `string`","description":"The HS Code of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`null` \\| `string`","description":"The origin country of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`null` \\| `string`","description":"The MID Code of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`null` \\| `string`","description":"The material of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`null` \\| `number`","description":"The weight of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`null` \\| `number`","description":"The length of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`null` \\| `number`","description":"The height of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`null` \\| `number`","description":"The width of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"[ProductOptionValueDTO](../../../../../product/interfaces/product.ProductOptionValueDTO/page.mdx)[]","description":"The associated product options.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"The associated product id.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product variant was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product variant was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product variant was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)","description":"The associated product.","optional":true,"defaultValue":"","expandable":true,"children":[]},{"name":"variant_rank","type":"`null` \\| `number`","description":"he ranking of the variant among other variants associated with the product.","optional":true,"defaultValue":"","expandable":falsLine truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-variant.updated`
</Table.Cell>
<Table.Cell>
Emitted when product variants are updated.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product variant
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -31,7 +31,7 @@ Learn more about adding rules to the product variant's prices in the Pricing Mod
:::
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/c1e6b81972cacebe040fd28dc5c6da82e60b3eac/packages/core/core-flows/src/product/workflows/update-products.ts#L410" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product/workflows/update-products.ts#L410" />
## Examples
@@ -361,6 +361,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### productsUpdated
This hook is executed after the products are updated. You can consume this hook to perform custom actions on the updated products.
#### Example
```ts
import { updateProductsWorkflow } from "@medusajs/medusa/core-flows"
updateProductsWorkflow.hooks.productsUpdated(
(async ({ products, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"products","type":"[ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"The handle of the product. The handle can be used to create slug URL paths.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"The subttle of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"The description of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"Whether the product is a gift card.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../../../product/types/product.ProductStatus/page.mdx)","description":"The status of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"The URL of the product's thumbnail.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`null` \\| `number`","description":"The width of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`null` \\| `number`","description":"The weight of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`null` \\| `number`","description":"The length of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`null` \\| `number`","description":"The height of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`null` \\| `string`","description":"The origin country of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`null` \\| `string`","description":"The HS Code of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`null` \\| `string`","description":"The MID Code of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`null` \\| `string`","description":"The material of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"`null` \\| [ProductCollectionDTO](../../../../../product/interfaces/product.ProductCollectionDTO/page.mdx)","description":"The associated product collection.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"collection_id","type":"`null` \\| `string`","description":"The associated product collection id.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`null` \\| [ProductTypeDTO](../../../../../product/interfaces/product.ProductTypeDTO/page.mdx)","description":"The associated product type.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"type_id","type":"`null` \\| `string`","description":"The associated product type id.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"[ProductTagDTO](../../../../../product/interfaces/product.ProductTagDTO/page.mdx)[]","description":"The associated product tags.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"variants","type":"[ProductVariantDTO](../../../../../product/interfaces/product.ProductVariantDTO/page.mdx)[]","description":"The associated product variants.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"options","type":"[ProductOptionDTO](../../../../../product/interfaces/product.ProductOptionDTO/page.mdx)[]","description":"The associated product options.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"images","type":"[ProductImageDTO](../../../../../product/interfaces/product.ProductImageDTO/page.mdx)[]","description":"The associated product images.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"external_id","type":"`null` \\| `string`","description":"The ID of the product in an external system. This is useful if you're integrating the product with a third-party service and want to maintain\na reference to the ID in the integrated service.","optional":false,"defaulLine truncated
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product.Workflows_Product/page.mdx#__type-35)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"products","type":"[ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"The handle of the product. The handle can be used to create slug URL paths.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"The subttle of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"The description of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"Whether the product is a gift card.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../../../product/types/product.ProductStatus/page.mdx)","description":"The status of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"The URL of the product's thumbnail.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`null` \\| `number`","description":"The width of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`null` \\| `number`","description":"The weight of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`null` \\| `number`","description":"The length of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`null` \\| `number`","description":"The height of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`null` \\| `string`","description":"The origin country of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`null` \\| `string`","description":"The HS Code of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`null` \\| `string`","description":"The MID Code of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`null` \\| `string`","description":"The material of the product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"`null` \\| [ProductCollectionDTO](../../../../../product/interfaces/product.ProductCollectionDTO/page.mdx)","description":"The associated product collection.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"collection_id","type":"`null` \\| `string`","description":"The associated product collection id.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`null` \\| [ProductTypeDTO](../../../../../product/interfaces/product.ProductTypeDTO/page.mdx)","description":"The associated product type.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"type_id","type":"`null` \\| `string`","description":"The associated product type id.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"[ProductTagDTO](../../../../../product/interfaces/product.ProductTagDTO/page.mdx)[]","description":"The associated product tags.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"variants","type":"[ProductVariantDTO](../../../../../product/interfaces/product.ProductVariantDTO/page.mdx)[]","description":"The associated product variants.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"options","type":"[ProductOptionDTO](../../../../../product/interfaces/product.ProductOptionDTO/page.mdx)[]","description":"The associated product options.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"images","type":"[ProductImageDTO](../../../../../product/interfaces/product.ProductImageDTO/page.mdx)[]","description":"The associated product images.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"external_id","type":"`null` \\| `string`","description":"The ID of the product in an external system. This is useful if you're integrating the product with a third-party service andLine truncated
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product.updated`
</Table.Cell>
<Table.Cell>
Emitted when products are updated.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -20,7 +20,7 @@ This workflow creates one or more product categories. It's used by the
You can use this workflow within your customizations or your own custom workflows, allowing you to
create product categories within your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/product-category/workflows/create-product-categories.ts#L45" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product-category/workflows/create-product-categories.ts#L45" />
## Examples
@@ -155,6 +155,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### categoriesCreated
This step is a hook that you can inject custom functionality into.
#### Example
```ts
import { createProductCategoriesWorkflow } from "@medusajs/medusa/core-flows"
createProductCategoriesWorkflow.hooks.categoriesCreated(
(async ({ categories, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"categories","type":"[ProductCategoryDTO](../../../../../product/interfaces/product.ProductCategoryDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"The handle of the product category. The handle can be used to create slug URL paths.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_active","type":"`boolean`","description":"Whether the product category is active.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_internal","type":"`boolean`","description":"Whether the product category is internal. This can be used to only show the product category to admins and hide it from customers.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rank","type":"`number`","description":"The ranking of the product category among sibling categories.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category","type":"`null` \\| [ProductCategoryDTO](../../../../../product/interfaces/product.ProductCategoryDTO/page.mdx)","description":"The associated parent category.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"parent_category_id","type":"`null` \\| `string`","description":"The associated parent category id.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"category_children","type":"[ProductCategoryDTO](../../../../../product/interfaces/product.ProductCategoryDTO/page.mdx)[]","description":"The associated child categories.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"products","type":"[ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)[]","description":"The associated products.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product category was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product category was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"The ranking of the product category among sibling categories.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product category was deleted.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="categoriesCreated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product_Category.Workflows_Product_Category/page.mdx#__type)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"categories","type":"[ProductCategoryDTO](../../../../../product/interfaces/product.ProductCategoryDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"The handle of the product category. The handle can be used to create slug URL paths.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_active","type":"`boolean`","description":"Whether the product category is active.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_internal","type":"`boolean`","description":"Whether the product category is internal. This can be used to only show the product category to admins and hide it from customers.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rank","type":"`number`","description":"The ranking of the product category among sibling categories.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category","type":"`null` \\| [ProductCategoryDTO](../../../../../product/interfaces/product.ProductCategoryDTO/page.mdx)","description":"The associated parent category.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"parent_category_id","type":"`null` \\| `string`","description":"The associated parent category id.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"category_children","type":"[ProductCategoryDTO](../../../../../product/interfaces/product.ProductCategoryDTO/page.mdx)[]","description":"The associated child categories.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"products","type":"[ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)[]","description":"The associated products.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product category was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product category was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"The ranking of the product category among sibling categories.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product category was deleted.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="categoriesCreated"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-category.created`
</Table.Cell>
<Table.Cell>
Emitted when product categories are created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product category
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -4,6 +4,7 @@ sidebar_label: deleteProductCategoriesWorkflow
sidebar_description: Delete product categories.
tags:
- product
- link
- event bus
- workflow
---
@@ -20,7 +21,7 @@ This workflow deletes one or more product categories. It's used by the
You can use this workflow within your customizations or your own custom workflows, allowing you to
delete product categories within your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/product-category/workflows/delete-product-categories.ts#L35" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product-category/workflows/delete-product-categories.ts#L39" />
## Examples
@@ -121,7 +122,7 @@ const myWorkflow = createWorkflow(
## Steps
<WorkflowDiagram workflow={{"name":"deleteProductCategoriesWorkflow","steps":[{"type":"step","name":"deleteProductCategoriesStep","description":"This step deletes one or more product categories.","link":"../../../Steps_Product_Category/functions/core_flows.Product_Category.Steps_Product_Category.deleteProductCategoriesStep/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},{"type":"hook","name":"categoriesDeleted","description":"This step is a hook that you can inject custom functionality into.","link":"#categoriesDeleted","depth":3}]}} />
<WorkflowDiagram workflow={{"name":"deleteProductCategoriesWorkflow","steps":[{"type":"step","name":"deleteProductCategoriesStep","description":"This step deletes one or more product categories.","link":"../../../Steps_Product_Category/functions/core_flows.Product_Category.Steps_Product_Category.deleteProductCategoriesStep/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},{"type":"step","name":"emitEventStep","description":"Emit an event.","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":2},{"type":"hook","name":"categoriesDeleted","description":"This step is a hook that you can inject custom functionality into.","link":"#categoriesDeleted","depth":3}]}} />
## Input
@@ -135,6 +136,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### categoriesDeleted
This step is a hook that you can inject custom functionality into.
#### Example
```ts
import { deleteProductCategoriesWorkflow } from "@medusajs/medusa/core-flows"
deleteProductCategoriesWorkflow.hooks.categoriesDeleted(
(async ({ ids }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"ids","type":"[DeleteProductCategoriesWorkflowInput](../../../../types/core_flows.DeleteProductCategoriesWorkflowInput/page.mdx)","description":"The IDs of product categories 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="categoriesDeleted"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product_Category.Workflows_Product_Category/page.mdx#__type-1)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"ids","type":"[DeleteProductCategoriesWorkflowInput](../../../../types/core_flows.DeleteProductCategoriesWorkflowInput/page.mdx)","description":"The IDs of product categories 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="categoriesDeleted"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-category.deleted`
</Table.Cell>
<Table.Cell>
Emitted when product categories are deleted.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product category
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -20,7 +20,7 @@ This workflow updates product categories matching specified filters. It's used b
You can use this workflow within your customizations or your own custom workflows, allowing you to
update product categories within your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/product-category/workflows/update-product-categories.ts#L46" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/product-category/workflows/update-product-categories.ts#L46" />
## Examples
@@ -167,6 +167,61 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### categoriesUpdated
This step is a hook that you can inject custom functionality into.
#### Example
```ts
import { updateProductCategoriesWorkflow } from "@medusajs/medusa/core-flows"
updateProductCategoriesWorkflow.hooks.categoriesUpdated(
(async ({ categories, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"categories","type":"[ProductCategoryDTO](../../../../../product/interfaces/product.ProductCategoryDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"The handle of the product category. The handle can be used to create slug URL paths.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_active","type":"`boolean`","description":"Whether the product category is active.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_internal","type":"`boolean`","description":"Whether the product category is internal. This can be used to only show the product category to admins and hide it from customers.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rank","type":"`number`","description":"The ranking of the product category among sibling categories.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category","type":"`null` \\| [ProductCategoryDTO](../../../../../product/interfaces/product.ProductCategoryDTO/page.mdx)","description":"The associated parent category.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"parent_category_id","type":"`null` \\| `string`","description":"The associated parent category id.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"category_children","type":"[ProductCategoryDTO](../../../../../product/interfaces/product.ProductCategoryDTO/page.mdx)[]","description":"The associated child categories.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"products","type":"[ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)[]","description":"The associated products.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product category was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product category was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"The ranking of the product category among sibling categories.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product category was deleted.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="categoriesUpdated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Product_Category.Workflows_Product_Category/page.mdx#__type-2)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"categories","type":"[ProductCategoryDTO](../../../../../product/interfaces/product.ProductCategoryDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"The handle of the product category. The handle can be used to create slug URL paths.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_active","type":"`boolean`","description":"Whether the product category is active.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_internal","type":"`boolean`","description":"Whether the product category is internal. This can be used to only show the product category to admins and hide it from customers.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rank","type":"`number`","description":"The ranking of the product category among sibling categories.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category","type":"`null` \\| [ProductCategoryDTO](../../../../../product/interfaces/product.ProductCategoryDTO/page.mdx)","description":"The associated parent category.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"parent_category_id","type":"`null` \\| `string`","description":"The associated parent category id.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"category_children","type":"[ProductCategoryDTO](../../../../../product/interfaces/product.ProductCategoryDTO/page.mdx)[]","description":"The associated child categories.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"products","type":"[ProductDTO](../../../../../product/interfaces/product.ProductDTO/page.mdx)[]","description":"The associated products.","optional":false,"defaultValue":"","expandable":true,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"When the product category was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"When the product category was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[MetadataType](../../../../../product/types/product.MetadataType/page.mdx)","description":"The ranking of the product category among sibling categories.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date`","description":"When the product category was deleted.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="categoriesUpdated"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`product-category.updated`
</Table.Cell>
<Table.Cell>
Emitted when product categories are updated.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the product category
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -20,7 +20,7 @@ allows you to create custom data models linked to the campaigns.
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around creating campaigns.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/promotion/workflows/create-campaigns.ts#L57" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/promotion/workflows/create-campaigns.ts#L57" />
## Examples
@@ -195,6 +195,22 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### campaignsCreated
This hook is executed after the campaigns are created. You can consume this hook to perform custom actions on the created campaigns.
#### Example
```ts
import { createCampaignsWorkflow } from "@medusajs/medusa/core-flows"
createCampaignsWorkflow.hooks.campaignsCreated(
(async ({ campaigns, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"campaigns","type":"[CampaignDTO](../../../../../promotion/interfaces/promotion.CampaignDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the campaign.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_identifier","type":"`string`","description":"The campaign identifier of the campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"starts_at","type":"`Date`","description":"The start date of the campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ends_at","type":"`Date`","description":"The end date of the campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"budget","type":"[CampaignBudgetDTO](../../../../../promotion/interfaces/promotion.CampaignBudgetDTO/page.mdx)","description":"The associated campaign budget.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"promotions","type":"[PromotionDTO](../../../../../promotion/interfaces/promotion.PromotionDTO/page.mdx)[]","description":"The associated promotions.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="campaignsCreated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Promotion.Workflows_Promotion/page.mdx#__type)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"campaigns","type":"[CampaignDTO](../../../../../promotion/interfaces/promotion.CampaignDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the campaign.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_identifier","type":"`string`","description":"The campaign identifier of the campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"starts_at","type":"`Date`","description":"The start date of the campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ends_at","type":"`Date`","description":"The end date of the campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"budget","type":"[CampaignBudgetDTO](../../../../../promotion/interfaces/promotion.CampaignBudgetDTO/page.mdx)","description":"The associated campaign budget.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"promotions","type":"[PromotionDTO](../../../../../promotion/interfaces/promotion.PromotionDTO/page.mdx)[]","description":"The associated promotions.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="campaignsCreated"/>
@@ -20,7 +20,7 @@ allows you to create custom data models linked to the promotions.
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around creating promotions.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/promotion/workflows/create-promotions.ts#L59" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/promotion/workflows/create-promotions.ts#L59" />
## Examples
@@ -203,6 +203,22 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### promotionsCreated
This hook is executed after the promotions are created. You can consume this hook to perform custom actions on the created promotions.
#### Example
```ts
import { createPromotionsWorkflow } from "@medusajs/medusa/core-flows"
createPromotionsWorkflow.hooks.promotionsCreated(
(async ({ promotions, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"promotions","type":"[PromotionDTO](../../../../../promotion/interfaces/promotion.PromotionDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the promotion.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"The code of the promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PromotionTypeValues](../../../../../promotion/types/promotion.PromotionTypeValues/page.mdx)","description":"The type of the promotion:\n\n- `standard` indicates that a promotion is a standard one applied with conditions.\n- `buyget` indicates that a promotion is a \"Buy X get Y\" promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PromotionStatusValues](../../../../../promotion/types/promotion.PromotionStatusValues/page.mdx)","description":"The status of the promotion:\n\n- `active` promotion is available for user to consume\n- `inactive` promotion is no longer available to the user\n- `draft` promotion is currently being prepared","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_automatic","type":"`boolean`","description":"Whether the promotion is applied automatically.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method","type":"[ApplicationMethodDTO](../../../../../promotion/interfaces/promotion.ApplicationMethodDTO/page.mdx)","description":"The associated application method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rules","type":"[PromotionRuleDTO](../../../../../promotion/interfaces/promotion.PromotionRuleDTO/page.mdx)[]","description":"The rules of the promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`null` \\| `string`","description":"The associated campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign","type":"[CampaignDTO](../../../../../promotion/interfaces/promotion.CampaignDTO/page.mdx)","description":"The associated campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="promotionsCreated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Promotion.Workflows_Promotion/page.mdx#__type-1)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"promotions","type":"[PromotionDTO](../../../../../promotion/interfaces/promotion.PromotionDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the promotion.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"The code of the promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PromotionTypeValues](../../../../../promotion/types/promotion.PromotionTypeValues/page.mdx)","description":"The type of the promotion:\n\n- `standard` indicates that a promotion is a standard one applied with conditions.\n- `buyget` indicates that a promotion is a \"Buy X get Y\" promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PromotionStatusValues](../../../../../promotion/types/promotion.PromotionStatusValues/page.mdx)","description":"The status of the promotion:\n\n- `active` promotion is available for user to consume\n- `inactive` promotion is no longer available to the user\n- `draft` promotion is currently being prepared","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_automatic","type":"`boolean`","description":"Whether the promotion is applied automatically.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method","type":"[ApplicationMethodDTO](../../../../../promotion/interfaces/promotion.ApplicationMethodDTO/page.mdx)","description":"The associated application method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rules","type":"[PromotionRuleDTO](../../../../../promotion/interfaces/promotion.PromotionRuleDTO/page.mdx)[]","description":"The rules of the promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`null` \\| `string`","description":"The associated campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign","type":"[CampaignDTO](../../../../../promotion/interfaces/promotion.CampaignDTO/page.mdx)","description":"The associated campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="promotionsCreated"/>
@@ -19,7 +19,7 @@ This workflow deletes one or more campaigns. It's used by the
You can use this workflow within your own customizations or custom workflows, allowing you to
delete campaigns within your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/promotion/workflows/delete-campaigns.ts#L39" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/promotion/workflows/delete-campaigns.ts#L39" />
## Examples
@@ -142,6 +142,22 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### campaignsDeleted
This step is a hook that you can inject custom functionality into.
#### Example
```ts
import { deleteCampaignsWorkflow } from "@medusajs/medusa/core-flows"
deleteCampaignsWorkflow.hooks.campaignsDeleted(
(async ({ ids }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","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="campaignsDeleted"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Promotion.Workflows_Promotion/page.mdx#__type-2)","description":"The input data for the hook.","optional":false,"defaultValue":"","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="campaignsDeleted"/>
@@ -19,7 +19,7 @@ This workflow deletes one or more promotions. It's used by the
You can use this workflow within your own customizations or custom workflows, allowing you to
delete promotions within your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/promotion/workflows/delete-promotions.ts#L39" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/promotion/workflows/delete-promotions.ts#L39" />
## Examples
@@ -142,6 +142,22 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### promotionsDeleted
This step is a hook that you can inject custom functionality into.
#### Example
```ts
import { deletePromotionsWorkflow } from "@medusajs/medusa/core-flows"
deletePromotionsWorkflow.hooks.promotionsDeleted(
(async ({ ids }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","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="promotionsDeleted"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Promotion.Workflows_Promotion/page.mdx#__type-3)","description":"The input data for the hook.","optional":false,"defaultValue":"","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="promotionsDeleted"/>
@@ -20,7 +20,7 @@ allows you to update custom data models linked to the campaigns.
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around updating campaigns.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/promotion/workflows/update-campaigns.ts#L52" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/promotion/workflows/update-campaigns.ts#L52" />
## Examples
@@ -175,6 +175,22 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### campaignsUpdated
This hook is executed after the campaigns are updated. You can consume this hook to perform custom actions on the updated campaigns.
#### Example
```ts
import { updateCampaignsWorkflow } from "@medusajs/medusa/core-flows"
updateCampaignsWorkflow.hooks.campaignsUpdated(
(async ({ campaigns, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"campaigns","type":"[CampaignDTO](../../../../../promotion/interfaces/promotion.CampaignDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the campaign.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_identifier","type":"`string`","description":"The campaign identifier of the campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"starts_at","type":"`Date`","description":"The start date of the campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ends_at","type":"`Date`","description":"The end date of the campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"budget","type":"[CampaignBudgetDTO](../../../../../promotion/interfaces/promotion.CampaignBudgetDTO/page.mdx)","description":"The associated campaign budget.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"promotions","type":"[PromotionDTO](../../../../../promotion/interfaces/promotion.PromotionDTO/page.mdx)[]","description":"The associated promotions.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="campaignsUpdated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Promotion.Workflows_Promotion/page.mdx#__type-4)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"campaigns","type":"[CampaignDTO](../../../../../promotion/interfaces/promotion.CampaignDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the campaign.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_identifier","type":"`string`","description":"The campaign identifier of the campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"starts_at","type":"`Date`","description":"The start date of the campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ends_at","type":"`Date`","description":"The end date of the campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"budget","type":"[CampaignBudgetDTO](../../../../../promotion/interfaces/promotion.CampaignBudgetDTO/page.mdx)","description":"The associated campaign budget.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"promotions","type":"[PromotionDTO](../../../../../promotion/interfaces/promotion.PromotionDTO/page.mdx)[]","description":"The associated promotions.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="campaignsUpdated"/>
@@ -21,7 +21,7 @@ allows you to create custom data models linked to the promotions.
You can also use this workflow within your customizations or your own custom workflows, allowing you to
update the status of promotions within your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/promotion/workflows/update-promotions-status.ts#L80" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/promotion/workflows/update-promotions-status.ts#L80" />
## Examples
@@ -172,6 +172,22 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### promotionStatusUpdated
This hook is executed after the promotions' status is updated. You can consume this hook to perform custom actions on the updated promotions.
#### Example
```ts
import { updatePromotionsStatusWorkflow } from "@medusajs/medusa/core-flows"
updatePromotionsStatusWorkflow.hooks.promotionStatusUpdated(
(async ({ promotions, additional_data }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"promotions","type":"[PromotionDTO](../../../../../promotion/interfaces/promotion.PromotionDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the promotion.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"The code of the promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PromotionTypeValues](../../../../../promotion/types/promotion.PromotionTypeValues/page.mdx)","description":"The type of the promotion:\n\n- `standard` indicates that a promotion is a standard one applied with conditions.\n- `buyget` indicates that a promotion is a \"Buy X get Y\" promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PromotionStatusValues](../../../../../promotion/types/promotion.PromotionStatusValues/page.mdx)","description":"The status of the promotion:\n\n- `active` promotion is available for user to consume\n- `inactive` promotion is no longer available to the user\n- `draft` promotion is currently being prepared","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_automatic","type":"`boolean`","description":"Whether the promotion is applied automatically.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method","type":"[ApplicationMethodDTO](../../../../../promotion/interfaces/promotion.ApplicationMethodDTO/page.mdx)","description":"The associated application method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rules","type":"[PromotionRuleDTO](../../../../../promotion/interfaces/promotion.PromotionRuleDTO/page.mdx)[]","description":"The rules of the promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`null` \\| `string`","description":"The associated campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign","type":"[CampaignDTO](../../../../../promotion/interfaces/promotion.CampaignDTO/page.mdx)","description":"The associated campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="promotionStatusUpdated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Promotion.Workflows_Promotion/page.mdx#__type-6)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"promotions","type":"[PromotionDTO](../../../../../promotion/interfaces/promotion.PromotionDTO/page.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the promotion.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"The code of the promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PromotionTypeValues](../../../../../promotion/types/promotion.PromotionTypeValues/page.mdx)","description":"The type of the promotion:\n\n- `standard` indicates that a promotion is a standard one applied with conditions.\n- `buyget` indicates that a promotion is a \"Buy X get Y\" promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PromotionStatusValues](../../../../../promotion/types/promotion.PromotionStatusValues/page.mdx)","description":"The status of the promotion:\n\n- `active` promotion is available for user to consume\n- `inactive` promotion is no longer available to the user\n- `draft` promotion is currently being prepared","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_automatic","type":"`boolean`","description":"Whether the promotion is applied automatically.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"application_method","type":"[ApplicationMethodDTO](../../../../../promotion/interfaces/promotion.ApplicationMethodDTO/page.mdx)","description":"The associated application method.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rules","type":"[PromotionRuleDTO](../../../../../promotion/interfaces/promotion.PromotionRuleDTO/page.mdx)[]","description":"The rules of the promotion.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign_id","type":"`null` \\| `string`","description":"The associated campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"campaign","type":"[CampaignDTO](../../../../../promotion/interfaces/promotion.CampaignDTO/page.mdx)","description":"The associated campaign.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_data","type":"`Record<string, unknown> | undefined`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="promotionStatusUpdated"/>
@@ -24,7 +24,7 @@ This workflow creates one or more regions. It's used by the
You can use this workflow within your own customizations or custom workflows, allowing you
to create regions in your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/region/workflows/create-regions.ts#L41" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/region/workflows/create-regions.ts#L41" />
## Examples
@@ -158,3 +158,42 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"CreateRegionsWorkflowOutput","type":"[CreateRegionsWorkflowOutput](../../../../../types/WorkflowTypes/RegionWorkflow/types/types.WorkflowTypes.RegionWorkflow.CreateRegionsWorkflowOutput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency code of the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"automatic_taxes","type":"`boolean`","description":"Setting to indicate whether taxes need to be applied automatically","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"countries","type":"[RegionCountryDTO](../../../../../region/interfaces/region.RegionCountryDTO/page.mdx)[]","description":"The countries of the region.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the country.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"iso_2","type":"`string`","description":"The ISO 2 code of the country.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"iso_3","type":"`string`","description":"The ISO 3 code of the country.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"num_code","type":"`string`","description":"The country's code number.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the country.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_name","type":"`string`","description":"The display name of the country.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"payment_providers","type":"[PaymentProviderDTO](../../../../../region/interfaces/region.PaymentProviderDTO/page.mdx)[]","description":"Payment providers available in the region","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the payment provider.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_enabled","type":"`boolean`","description":"Whether the payment provider is enabled.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"`string`","description":"The date the region was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"The date the region was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, any>`","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="createRegionsWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`region.created`
</Table.Cell>
<Table.Cell>
Emitted when regions are created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the region
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -4,6 +4,7 @@ sidebar_label: deleteRegionsWorkflow
sidebar_description: Delete one or more regions.
tags:
- region
- link
- event bus
- workflow
---
@@ -14,13 +15,13 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
This documentation provides a reference to the `deleteRegionsWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
This workflow deletes one or more regions. It's used by the
This workflow deletes one or more regions. It's used by the
[Delete Region Admin API Route](https://docs.medusajs.com/api/admin#regions\_deleteregionsid).
You can use this workflow within your own customizations or custom workflows, allowing you
to delete regions in your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/region/workflows/delete-regions.ts#L32" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/region/workflows/delete-regions.ts#L33" />
## Examples
@@ -129,8 +130,47 @@ const myWorkflow = createWorkflow(
## Steps
<WorkflowDiagram workflow={{"name":"deleteRegionsWorkflow","steps":[{"type":"step","name":"deleteRegionsStep","description":"This step deletes one or more regions.","link":"../../../Steps_Region/functions/core_flows.Region.Steps_Region.deleteRegionsStep/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}]}} />
<WorkflowDiagram workflow={{"name":"deleteRegionsWorkflow","steps":[{"type":"step","name":"deleteRegionsStep","description":"This step deletes one or more regions.","link":"../../../Steps_Region/functions/core_flows.Region.Steps_Region.deleteRegionsStep/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},{"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":"DeleteRegionsWorkflowInput","type":"[DeleteRegionsWorkflowInput](../../../../types/core_flows.DeleteRegionsWorkflowInput/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="deleteRegionsWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`region.deleted`
</Table.Cell>
<Table.Cell>
Emitted when regions are deleted.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the region
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -24,7 +24,7 @@ This workflow updates regions matching the specified filters. It's used by the
You can use this workflow within your own customizations or custom workflows, allowing you
to update regions in your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/region/workflows/update-regions.ts#L41" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/region/workflows/update-regions.ts#L41" />
## Examples
@@ -162,3 +162,42 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"UpdateRegionsWorkflowOutput","type":"[UpdateRegionsWorkflowOutput](../../../../../types/WorkflowTypes/RegionWorkflow/types/types.WorkflowTypes.RegionWorkflow.UpdateRegionsWorkflowOutput/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The currency code of the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"automatic_taxes","type":"`boolean`","description":"Setting to indicate whether taxes need to be applied automatically","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"countries","type":"[RegionCountryDTO](../../../../../region/interfaces/region.RegionCountryDTO/page.mdx)[]","description":"The countries of the region.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the country.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"iso_2","type":"`string`","description":"The ISO 2 code of the country.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"iso_3","type":"`string`","description":"The ISO 3 code of the country.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"num_code","type":"`string`","description":"The country's code number.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the country.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_name","type":"`string`","description":"The display name of the country.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"payment_providers","type":"[PaymentProviderDTO](../../../../../region/interfaces/region.PaymentProviderDTO/page.mdx)[]","description":"Payment providers available in the region","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the payment provider.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_enabled","type":"`boolean`","description":"Whether the payment provider is enabled.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"`string`","description":"The date the region was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"The date the region was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, any>`","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="updateRegionsWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`region.updated`
</Table.Cell>
<Table.Cell>
Emitted when regions are updated.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the region
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -20,7 +20,7 @@ This workflow creates one or more sales channels. It's used by the
You can use this workflow within your customizations or your own custom workflows, allowing you to
create sales channels within your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/sales-channel/workflows/create-sales-channels.ts#L54" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/sales-channel/workflows/create-sales-channels.ts#L54" />
## Examples
@@ -146,3 +146,42 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"CreateSalesChannelsWorkflowOutput","type":"[CreateSalesChannelsWorkflowOutput](../../../../types/core_flows.CreateSalesChannelsWorkflowOutput/page.mdx)","optional":false,"defaultValue":"","description":"The created sales channels.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"The description of the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_disabled","type":"`boolean`","description":"Whether the sales channel is disabled.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"locations","type":"[SalesChannelLocationDTO](../../../../../sales_channel/interfaces/sales_channel.SalesChannelLocationDTO/page.mdx)[]","description":"The locations of the sales channel.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"sales_channel_id","type":"`string`","description":"The associated sales channel's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"The associated location's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sales_channel","type":"[SalesChannelDTO](../../../../../sales_channel/interfaces/sales_channel.SalesChannelDTO/page.mdx)","description":"The associated sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"The description of the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_disabled","type":"`boolean`","description":"Whether the sales channel is disabled.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"locations","type":"[SalesChannelLocationDTO](../../../../../sales_channel/interfaces/sales_channel.SalesChannelLocationDTO/page.mdx)[]","description":"The locations of the sales channel.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createSalesChannelsWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`sales-channel.created`
</Table.Cell>
<Table.Cell>
Emitted when sales channels are created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the sales channel
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -21,7 +21,7 @@ This workflow deletes one or more sales channels. It's used by the
You can use this workflow within your customizations or your own custom workflows, allowing you to
delete sales channels within your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/sales-channel/workflows/delete-sales-channels.ts#L42" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/sales-channel/workflows/delete-sales-channels.ts#L42" />
## Examples
@@ -135,3 +135,42 @@ const myWorkflow = createWorkflow(
## Input
<TypeList types={[{"name":"DeleteSalesChannelsWorkflowInput","type":"[DeleteSalesChannelsWorkflowInput](../../../../types/core_flows.DeleteSalesChannelsWorkflowInput/page.mdx)","optional":false,"defaultValue":"","description":"The data to delete sales channels.","expandable":false,"children":[{"name":"ids","type":"`string`[]","description":"The IDs of the sales channels 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="deleteSalesChannelsWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`sales-channel.deleted`
</Table.Cell>
<Table.Cell>
Emitted when sales channels are deleted.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the sales channel
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -20,7 +20,7 @@ This workflow updates sales channels matching the specified conditions. It's use
You can use this workflow within your customizations or your own custom workflows, allowing you to
update sales channels within your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/sales-channel/workflows/update-sales-channels.ts#L60" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/sales-channel/workflows/update-sales-channels.ts#L60" />
## Examples
@@ -158,3 +158,42 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"UpdateSalesChannelsWorkflowOutput","type":"[UpdateSalesChannelsWorkflowOutput](../../../../types/core_flows.UpdateSalesChannelsWorkflowOutput/page.mdx)","optional":false,"defaultValue":"","description":"The updated sales channels.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"The description of the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_disabled","type":"`boolean`","description":"Whether the sales channel is disabled.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"locations","type":"[SalesChannelLocationDTO](../../../../../sales_channel/interfaces/sales_channel.SalesChannelLocationDTO/page.mdx)[]","description":"The locations of the sales channel.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"sales_channel_id","type":"`string`","description":"The associated sales channel's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"The associated location's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sales_channel","type":"[SalesChannelDTO](../../../../../sales_channel/interfaces/sales_channel.SalesChannelDTO/page.mdx)","description":"The associated sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"The description of the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_disabled","type":"`boolean`","description":"Whether the sales channel is disabled.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"locations","type":"[SalesChannelLocationDTO](../../../../../sales_channel/interfaces/sales_channel.SalesChannelLocationDTO/page.mdx)[]","description":"The locations of the sales channel.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="updateSalesChannelsWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`sales-channel.updated`
</Table.Cell>
<Table.Cell>
Emitted when sales channels are updated.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the sales channel
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -19,7 +19,7 @@ This workflow creates one or more stock locations. It's used by the
You can use this workflow within your own customizations or custom workflows, allowing you
to create stock locations in your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/stock-location/workflows/create-stock-locations.ts#L45" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/stock-location/workflows/create-stock-locations.ts#L45" />
## Examples
@@ -154,6 +154,22 @@ Learn more about [Hooks](https://docs.medusajs.com/learn/fundamentals/workflows/
### stockLocationsCreated
This step is a hook that you can inject custom functionality into.
#### Example
```ts
import { createStockLocationsWorkflow } from "@medusajs/medusa/core-flows"
createStockLocationsWorkflow.hooks.stockLocationsCreated(
(async ({ stockLocations }, { container }) => {
//TODO
})
)
```
#### Input
Handlers consuming this hook accept the following input.
<TypeList types={[{"name":"input","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"stockLocations","type":"[StockLocationDTO](../../../../../types/StockLocationTypes/types/types.StockLocationTypes.StockLocationDTO/page.mdx)[]","description":"","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](../../../../../types/StockLocationTypes/types/types.StockLocationTypes.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="stockLocationsCreated"/>
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Stock_Location.Workflows_Stock_Location/page.mdx#__type)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"stockLocations","type":"[StockLocationDTO](../../../../../types/StockLocationTypes/types/types.StockLocationTypes.StockLocationDTO/page.mdx)[]","description":"","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](../../../../../types/StockLocationTypes/types/types.StockLocationTypes.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="stockLocationsCreated"/>
@@ -23,7 +23,7 @@ Learn more about basic authentication flows in [this documentation](https://docs
You can use this workflow within your customizations or your own custom workflows, allowing you to
register or create user accounts within your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/user/workflows/create-user-account.ts#L52" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/user/workflows/create-user-account.ts#L52" />
## Examples
@@ -161,3 +161,42 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"UserDTO","type":"[UserDTO](../../../../../user/interfaces/user.UserDTO/page.mdx)","optional":false,"defaultValue":"","description":"The user details.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"The email of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"avatar_url","type":"`null` \\| `string`","description":"The avatar URL of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The creation date of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The updated date of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createUserAccountWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`user.created`
</Table.Cell>
<Table.Cell>
Emitted when users are created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the user
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -24,7 +24,7 @@ setAuthAppMetadataStep. Learn more about auth identities in
You can use this workflow within your customizations or your own custom workflows, allowing you to
create users within your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/user/workflows/create-users.ts#L40" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/user/workflows/create-users.ts#L40" />
## Examples
@@ -158,3 +158,42 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"UserDTO[]","type":"[UserDTO](../../../../../user/interfaces/user.UserDTO/page.mdx)[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"The email of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"avatar_url","type":"`null` \\| `string`","description":"The avatar URL of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The creation date of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The updated date of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="createUsersWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`user.created`
</Table.Cell>
<Table.Cell>
Emitted when users are created.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the user
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -4,6 +4,7 @@ sidebar_label: deleteUsersWorkflow
sidebar_description: Delete one or more users.
tags:
- user
- link
- event bus
- workflow
---
@@ -14,7 +15,7 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
This documentation provides a reference to the `deleteUsersWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.
This workflow deletes one or more users. It's used by other workflows
This workflow deletes one or more users. It's used by other workflows
like [removeUserAccountWorkflow](../core_flows.User.Workflows_User.removeUserAccountWorkflow/page.mdx). If you use this workflow directly,
you must also remove the association to the auth identity using the
setAuthAppMetadataStep. Learn more about auth identities in
@@ -23,7 +24,7 @@ setAuthAppMetadataStep. Learn more about auth identities in
You can use this workflow within your customizations or your own custom workflows, allowing you to
delete users within your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/user/workflows/delete-users.ts#L34" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/user/workflows/delete-users.ts#L35" />
## Examples
@@ -132,8 +133,47 @@ const myWorkflow = createWorkflow(
## Steps
<WorkflowDiagram workflow={{"name":"deleteUsersWorkflow","steps":[{"type":"step","name":"deleteUsersStep","description":"This step deletes one or more users.","link":"../../../Steps_User/functions/core_flows.User.Steps_User.deleteUsersStep/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}]}} />
<WorkflowDiagram workflow={{"name":"deleteUsersWorkflow","steps":[{"type":"step","name":"deleteUsersStep","description":"This step deletes one or more users.","link":"../../../Steps_User/functions/core_flows.User.Steps_User.deleteUsersStep/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},{"type":"step","name":"emitEventStep","description":"Emit an event.","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":2}]}} />
## Input
<TypeList types={[{"name":"DeleteUserWorkflowInput","type":"[DeleteUserWorkflowInput](../../../../../types/WorkflowTypes/UserWorkflow/interfaces/types.WorkflowTypes.UserWorkflow.DeleteUserWorkflowInput/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="deleteUsersWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`user.deleted`
</Table.Cell>
<Table.Cell>
Emitted when users are deleted.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the user
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -7,6 +7,7 @@ tags:
- auth
- workflow
- user
- link
- event bus
---
@@ -22,7 +23,7 @@ by the [Delete User Admin API Route](https://docs.medusajs.com/api/admin#users\_
You can use this workflow within your customizations or your own custom workflows, allowing you to
delete users within your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/user/workflows/remove-user-account.ts#L41" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/user/workflows/remove-user-account.ts#L41" />
## Examples
@@ -140,3 +141,42 @@ const myWorkflow = createWorkflow(
## Output
<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="removeUserAccountWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`user.deleted`
</Table.Cell>
<Table.Cell>
Emitted when users are deleted.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the user
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -20,7 +20,7 @@ This workflow updates one or more users. It's used by the
You can use this workflow within your customizations or your own custom workflows, allowing you to
update users within your custom flows.
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/876a14eb98aed54360312b9b215599aa46faccd8/packages/core/core-flows/src/user/workflows/update-users.ts#L37" />
<SourceCodeLink link="https://github.com/medusajs/medusa/blob/ecf3556589c1fb64ad8bdc0b88307b11a6f7c89f/packages/core/core-flows/src/user/workflows/update-users.ts#L37" />
## Examples
@@ -150,3 +150,42 @@ const myWorkflow = createWorkflow(
## Output
<TypeList types={[{"name":"UserDTO[]","type":"[UserDTO](../../../../../user/interfaces/user.UserDTO/page.mdx)[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"The email of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"The first name of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"The last name of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"avatar_url","type":"`null` \\| `string`","description":"The avatar URL of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The creation date of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The updated date of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="updateUsersWorkflow"/>
## Emitted Events
This section lists the events that are either triggered by the `emitEventStep` in the workflow, or by another workflow executed within this workflow.
You can listen to these events in a subscriber, as explained in the [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers) documentation.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Payload
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`user.updated`
</Table.Cell>
<Table.Cell>
Emitted when users are updated.
</Table.Cell>
<Table.Cell>
```ts blockStyle="inline"
[{
id, // The ID of the user
}]
```
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
@@ -787,6 +787,135 @@ Emitted when users are deleted.
---
## Invite Events
### Summary
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
[invite.accepted](#inviteaccepted)
</Table.Cell>
<Table.Cell>
Emitted when an invite is accepted.
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
[invite.created](#invitecreated)
</Table.Cell>
<Table.Cell>
Emitted when invites are created. You can listen to this event
to send an email to the invited users, for example.
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
[invite.deleted](#invitedeleted)
</Table.Cell>
<Table.Cell>
Emitted when invites are deleted.
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
[invite.resent](#inviteresent)
</Table.Cell>
<Table.Cell>
Emitted when invites should be resent because their token was
refreshed. You can listen to this event to send an email to the invited users,
for example.
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
### `invite.accepted`
Emitted when an invite is accepted.
#### Payload
```ts
{
id, // The ID of the invite
}
```
#### Workflows Emitting this Event
- [acceptInviteWorkflow](/references/medusa-workflows/acceptInviteWorkflow)
---
### `invite.created`
Emitted when invites are created. You can listen to this event
to send an email to the invited users, for example.
#### Payload
```ts
[{
id, // The ID of the invite
}]
```
#### Workflows Emitting this Event
- [createInvitesWorkflow](/references/medusa-workflows/createInvitesWorkflow)
---
### `invite.deleted`
Emitted when invites are deleted.
#### Payload
```ts
[{
id, // The ID of the invite
}]
```
#### Workflows Emitting this Event
- [deleteInvitesWorkflow](/references/medusa-workflows/deleteInvitesWorkflow)
---
### `invite.resent`
Emitted when invites should be resent because their token was
refreshed. You can listen to this event to send an email to the invited users,
for example.
#### Payload
```ts
[{
id, // The ID of the invite
}]
```
#### Workflows Emitting this Event
- [refreshInviteTokensWorkflow](/references/medusa-workflows/refreshInviteTokensWorkflow)
---
## Auth Events
### Summary
@@ -1624,135 +1753,6 @@ Emitted when product options are deleted.
---
## Invite Events
### Summary
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>
Event
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
[invite.accepted](#inviteaccepted)
</Table.Cell>
<Table.Cell>
Emitted when an invite is accepted.
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
[invite.created](#invitecreated)
</Table.Cell>
<Table.Cell>
Emitted when invites are created. You can listen to this event
to send an email to the invited users, for example.
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
[invite.deleted](#invitedeleted)
</Table.Cell>
<Table.Cell>
Emitted when invites are deleted.
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
[invite.resent](#inviteresent)
</Table.Cell>
<Table.Cell>
Emitted when invites should be resent because their token was
refreshed. You can listen to this event to send an email to the invited users,
for example.
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
### `invite.accepted`
Emitted when an invite is accepted.
#### Payload
```ts
{
id, // The ID of the invite
}
```
#### Workflows Emitting this Event
- [acceptInviteWorkflow](/references/medusa-workflows/acceptInviteWorkflow)
---
### `invite.created`
Emitted when invites are created. You can listen to this event
to send an email to the invited users, for example.
#### Payload
```ts
[{
id, // The ID of the invite
}]
```
#### Workflows Emitting this Event
- [createInvitesWorkflow](/references/medusa-workflows/createInvitesWorkflow)
---
### `invite.deleted`
Emitted when invites are deleted.
#### Payload
```ts
[{
id, // The ID of the invite
}]
```
#### Workflows Emitting this Event
- [deleteInvitesWorkflow](/references/medusa-workflows/deleteInvitesWorkflow)
---
### `invite.resent`
Emitted when invites should be resent because their token was
refreshed. You can listen to this event to send an email to the invited users,
for example.
#### Payload
```ts
[{
id, // The ID of the invite
}]
```
#### Workflows Emitting this Event
- [refreshInviteTokensWorkflow](/references/medusa-workflows/refreshInviteTokensWorkflow)
---
## Region Events
### Summary