|
|
|
@@ -538,12 +538,12 @@ If you get a type error on resolving the Preorder Module, run the Medusa applica
|
|
|
|
|
</Note>
|
|
|
|
|
|
|
|
|
|
export const updatePreorderVariantStepHighlights = [
|
|
|
|
|
["16", "preorderModuleService", "Resolve the Preorder Module's service from the Medusa container."],
|
|
|
|
|
["20", "oldData", "Retrieve existing record to undo updates if an error occurs."],
|
|
|
|
|
["24", "preorderVariant", "Update the pre-order variant."],
|
|
|
|
|
["28", "preorderVariant", "Return the updated pre-order variant."],
|
|
|
|
|
["28", "oldData", "Pass the old data to the compensation function."],
|
|
|
|
|
["39", "updatePreorderVariants", "Undo updates if an error occurs during the workflow execution."]
|
|
|
|
|
["17", "preorderModuleService", "Resolve the Preorder Module's service from the Medusa container."],
|
|
|
|
|
["21", "oldData", "Retrieve existing record to undo updates if an error occurs."],
|
|
|
|
|
["25", "preorderVariant", "Update the pre-order variant."],
|
|
|
|
|
["29", "preorderVariant", "Return the updated pre-order variant."],
|
|
|
|
|
["29", "oldData", "Pass the old data to the compensation function."],
|
|
|
|
|
["40", "updatePreorderVariants", "Undo updates if an error occurs during the workflow execution."]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
```ts title="src/workflows/steps/update-preorder-variant.ts" highlights={updatePreorderVariantStepHighlights}
|
|
|
|
@@ -623,10 +623,10 @@ The `createPreorderVariantStep` creates a pre-order variant record.
|
|
|
|
|
To create the step, create the file `src/workflows/steps/create-preorder-variant.ts` with the following content:
|
|
|
|
|
|
|
|
|
|
export const createPreorderVariantStepHighlights = [
|
|
|
|
|
["15", "preorderVariant", "Create the pre-order variant."],
|
|
|
|
|
["19", "preorderVariant", "Return the created pre-order variant."],
|
|
|
|
|
["19", "id", "Pass the ID to the compensation function."],
|
|
|
|
|
["30", "deletePreorderVariants", "Delete the pre-order variant if an error occurs during the workflow execution."]
|
|
|
|
|
["16", "preorderVariant", "Create the pre-order variant."],
|
|
|
|
|
["20", "preorderVariant", "Return the created pre-order variant."],
|
|
|
|
|
["20", "id", "Pass the ID to the compensation function."],
|
|
|
|
|
["31", "deletePreorderVariants", "Delete the pre-order variant if an error occurs during the workflow execution."]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
```ts title="src/workflows/steps/create-preorder-variant.ts" highlights={createPreorderVariantStepHighlights}
|
|
|
|
@@ -811,7 +811,7 @@ export const upsertPreorderVariantRouteHighlights = [
|
|
|
|
|
["10", "UpsertPreorderVariantSchema", "The schema to validate the request body."],
|
|
|
|
|
["18", "POST", "Expose a POST API route."],
|
|
|
|
|
["24", "upsertProductVariantPreorderWorkflow", "Execute the workflow to create or update pre-order variant configurations."],
|
|
|
|
|
["32", "preorder_variant", "Return the created or updated pre-order variant in the response."],
|
|
|
|
|
["33", "preorder_variant", "Return the created or updated pre-order variant in the response."],
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
```ts title="src/api/admin/variants/[id]/preorders/route.ts" highlights={upsertPreorderVariantRouteHighlights}
|
|
|
|
@@ -944,12 +944,12 @@ The `disablePreorderVariantStep` changes the status of a pre-order variant recor
|
|
|
|
|
Create the file `src/workflows/steps/disable-preorder-variant.ts` with the following content:
|
|
|
|
|
|
|
|
|
|
export const disablePreorderVariantStepHighlights = [
|
|
|
|
|
["15", "oldData", "Retrieve existing record to undo updates if an error occurs."],
|
|
|
|
|
["17", "preorderVariant", "Update the pre-order variant."],
|
|
|
|
|
["19", "DISABLED", "Set the pre-order variant's status to `disabled`."],
|
|
|
|
|
["22", "preorderVariant", "Return the updated pre-order variant."],
|
|
|
|
|
["22", "oldData", "Pass the old data to the compensation function."],
|
|
|
|
|
["31", "updatePreorderVariants", "Undo updates if an error occurs during the workflow execution."]
|
|
|
|
|
["16", "oldData", "Retrieve existing record to undo updates if an error occurs."],
|
|
|
|
|
["18", "preorderVariant", "Update the pre-order variant."],
|
|
|
|
|
["20", "DISABLED", "Set the pre-order variant's status to `disabled`."],
|
|
|
|
|
["23", "preorderVariant", "Return the updated pre-order variant."],
|
|
|
|
|
["23", "oldData", "Pass the old data to the compensation function."],
|
|
|
|
|
["32", "updatePreorderVariants", "Undo updates if an error occurs during the workflow execution."]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
```ts title="src/workflows/steps/disable-preorder-variant.ts" highlights={disablePreorderVariantStepHighlights}
|
|
|
|
@@ -1688,9 +1688,9 @@ The `createPreordersStep` creates a `Preorder` record for each pre-order variant
|
|
|
|
|
Create the file `src/workflows/steps/create-preorders.ts` with the following content:
|
|
|
|
|
|
|
|
|
|
export const createPreordersStepHighlights = [
|
|
|
|
|
["16", "preorders", "Create pre-orders."],
|
|
|
|
|
["23", "preorders", "Return the pre-orders."],
|
|
|
|
|
["32", "deletePreorders", "Delete pre-orders if an error occurs during the workflow execution."],
|
|
|
|
|
["17", "preorders", "Create pre-orders."],
|
|
|
|
|
["24", "preorders", "Return the pre-orders."],
|
|
|
|
|
["33", "deletePreorders", "Delete pre-orders if an error occurs during the workflow execution."],
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
```ts title="src/workflows/steps/create-preorders.ts" highlights={createPreordersStepHighlights}
|
|
|
|
@@ -1927,7 +1927,7 @@ export const validateCartHookHighlights = [
|
|
|
|
|
["32", "variantsToAdd", "Retrieve the pre-order variants of the new items being added to the cart."],
|
|
|
|
|
["42", "cartHasPreorderVariants", "Check if the cart has pre-order variants."],
|
|
|
|
|
["48", "newItemsHavePreorderVariants", "Check if the new items being added have pre-order variants."],
|
|
|
|
|
["55", "throw MedusaError", "Throw an error if the cart has mixed pre-order and available items."],
|
|
|
|
|
["55", "MedusaError", "Throw an error if the cart has mixed pre-order and available items."],
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
```ts title="src/workflows/hooks/validate-cart.ts" highlights={validateCartHookHighlights}
|
|
|
|
@@ -2759,12 +2759,12 @@ The `updatePreordersStep` updates the details of pre-order records.
|
|
|
|
|
Create the file `src/workflows/steps/update-preorders.ts` with the following content:
|
|
|
|
|
|
|
|
|
|
export const updatePreordersHighlights = [
|
|
|
|
|
["13", "preorders", "The pre-orders to update."],
|
|
|
|
|
["16", "oldPreorders", "The pre-orders before the update."],
|
|
|
|
|
["20", "updatedPreorders", "Update the pre-orders."],
|
|
|
|
|
["24", "updatedPreorders", "Return the updated pre-orders."],
|
|
|
|
|
["24", "oldPreorders", "Pass the old pre-orders to the compensation function."],
|
|
|
|
|
["33", "updatePreorders", "Revert the pre-order updates if an error occurs during the workflow's execution."]
|
|
|
|
|
["14", "preorders", "The pre-orders to update."],
|
|
|
|
|
["17", "oldPreorders", "The pre-orders before the update."],
|
|
|
|
|
["21", "updatedPreorders", "Update the pre-orders."],
|
|
|
|
|
["25", "updatedPreorders", "Return the updated pre-orders."],
|
|
|
|
|
["25", "oldPreorders", "Pass the old pre-orders to the compensation function."],
|
|
|
|
|
["34", "updatePreorders", "Revert the pre-order updates if an error occurs during the workflow's execution."]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
```ts title="src/workflows/steps/update-preorders.ts" highlights={updatePreordersHighlights}
|
|
|
|
@@ -2964,14 +2964,7 @@ export const retrieveItemsToFulfillStep = createStep(
|
|
|
|
|
|
|
|
|
|
Then, update the workflow to the following:
|
|
|
|
|
|
|
|
|
|
export const fulfillPreorderWorkflowHighlights2 = [
|
|
|
|
|
["22"], ["23"], ["24"], ["25"], ["37"], ["55"], ["56"], ["57"], ["58"],
|
|
|
|
|
["59"], ["60"], ["61"], ["62"], ["63"], ["64"], ["65"], ["66"], ["67"],
|
|
|
|
|
["68"], ["69"], ["70"], ["71"], ["72"], ["73"], ["74"], ["75"], ["76"],
|
|
|
|
|
["77"], ["78"], ["79"], ["80"],
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
```ts title="src/workflows/fulfill-preorder.ts" highlights={fulfillPreorderWorkflowHighlights2}
|
|
|
|
|
```ts title="src/workflows/fulfill-preorder.ts"
|
|
|
|
|
import { InferTypeOf } from "@medusajs/framework/types"
|
|
|
|
|
import { PreorderVariant } from "../modules/preorder/models/preorder-variant"
|
|
|
|
|
import { createWorkflow, transform, when, WorkflowResponse } from "@medusajs/framework/workflows-sdk"
|
|
|
|
@@ -3135,7 +3128,7 @@ export const fulfillPreordersJobHighlights2 = [
|
|
|
|
|
["24", "available_date", "Retrieve only the pre-order variants available today."],
|
|
|
|
|
["43", "unfulfilledPreorders", "The unfulfilled pre-orders retrieved."],
|
|
|
|
|
["44", "preorderMetadata", "The pagination details of the pre-order query."],
|
|
|
|
|
["66", "fulfillPreorderWorkflow.run", "Fulfill a pre-order of the variant."],
|
|
|
|
|
["66", "fulfillPreorderWorkflow", "Fulfill a pre-order of the variant."],
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
```ts title="src/jobs/fulfill-preorders.ts" highlights={fulfillPreordersJobHighlights2}
|
|
|
|
@@ -3498,7 +3491,7 @@ export const orderCanceledHighlights = [
|
|
|
|
|
["14", "workflowInput", "Prepare the input to pass to the workflow."],
|
|
|
|
|
["24", "preorders", "Retrieve the pre-orders of the order."],
|
|
|
|
|
["41", "push", "Add the pre-orders to the workflow input."],
|
|
|
|
|
["46", "cancelPreordersWorkflow.run", "Execute the cancel pre-orders workflow."],
|
|
|
|
|
["46", "cancelPreordersWorkflow", "Execute the cancel pre-orders workflow."],
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
```ts title="src/subscribers/order-canceled.ts" highlights={orderCanceledHighlights}
|
|
|
|
@@ -3642,10 +3635,7 @@ Create the file `src/workflows/steps/retrieve-preorder-updates.ts` with the foll
|
|
|
|
|
export const retrievePreorderUpdatesStepHighlights = [
|
|
|
|
|
["20", "preordersToCancel", "The pre-orders to cancel."],
|
|
|
|
|
["24", "preordersToCreate", "The pre-orders to create."],
|
|
|
|
|
["20", "preorder_variant", "The pre-order variant associated with the item."],
|
|
|
|
|
["32", "", "Find the new pre-order items."],
|
|
|
|
|
["44", "push", "Add the pre-order variant to the pre-orders to create."],
|
|
|
|
|
["50", "", "Find the pre-order items that need to be canceled."],
|
|
|
|
|
["55", "push", "Add the pre-order to the pre-orders to cancel."],
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|