diff --git a/.changeset/fluffy-lilies-invite.md b/.changeset/fluffy-lilies-invite.md new file mode 100644 index 0000000..2f6b09f --- /dev/null +++ b/.changeset/fluffy-lilies-invite.md @@ -0,0 +1,5 @@ +--- +"@codee-sh/medusa-plugin-automations": patch +--- + +Add transformContext from -emails plugin diff --git a/package.json b/package.json index d38666d..914ecb4 100755 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ }, "devDependencies": { "@changesets/cli": "^2.29.8", - "@codee-sh/medusa-plugin-notification-emails": "0.1.0", + "@codee-sh/medusa-plugin-notification-emails": "0.1.1", "@medusajs/admin-sdk": "2.8.8", "@medusajs/cli": "2.8.8", "@medusajs/framework": "2.8.8", diff --git a/src/modules/mpn-automation/services/email-action-service.ts b/src/modules/mpn-automation/services/email-action-service.ts index b0743e5..fde0e5b 100644 --- a/src/modules/mpn-automation/services/email-action-service.ts +++ b/src/modules/mpn-automation/services/email-action-service.ts @@ -1,6 +1,8 @@ import { FieldConfig } from "../types" import { BaseActionService } from "./base-action-service" import { renderTemplate } from "@codee-sh/medusa-plugin-notification-emails/templates/emails" +import { transformContext } from "@codee-sh/medusa-plugin-notification-emails/utils" + import type { TemplateData, TemplateOptionsType, @@ -95,14 +97,16 @@ export class EmailActionService extends BaseActionService { const { templateName, context, + contextType, options, customTemplateFunction, } = params - // Use external plugin's renderTemplate function + const transformedContext = transformContext(contextType, context) + const result = await renderTemplate( templateName, - context, + transformedContext, options || {}, customTemplateFunction ) diff --git a/src/modules/mpn-automation/types/modules/order/order.ts b/src/modules/mpn-automation/types/modules/order/order.ts index d1caf38..908931a 100644 --- a/src/modules/mpn-automation/types/modules/order/order.ts +++ b/src/modules/mpn-automation/types/modules/order/order.ts @@ -560,4 +560,5 @@ export const ORDER_QUERY_FIELDS = [ "order.fulfillments.*", "order.credit_lines.*", "order.summary.*", + "order.payment_collections.*", ] diff --git a/src/subscribers/mpn.automation.action.email.executed.ts b/src/subscribers/mpn.automation.action.email.executed.ts index 55032bf..e9489c6 100644 --- a/src/subscribers/mpn.automation.action.email.executed.ts +++ b/src/subscribers/mpn.automation.action.email.executed.ts @@ -29,8 +29,6 @@ export default async function mpnAutomationActionEmailExecutedHandler({ contextType, } = data - console.log(eventName, data) - const { result } = await runEmailActionWorkflow( container ).run({ diff --git a/src/workflows/order/steps/get-order-by-id.ts b/src/workflows/order/steps/get-order-by-id.ts index 5c77edc..de2e920 100644 --- a/src/workflows/order/steps/get-order-by-id.ts +++ b/src/workflows/order/steps/get-order-by-id.ts @@ -1,4 +1,4 @@ -import type { OrderTypes } from "@medusajs/framework/types" +import type { OrderTypes, CustomerTypes } from "@medusajs/framework/types" import { ContainerRegistrationKeys, MedusaError, @@ -15,7 +15,9 @@ export interface GetOrderByIdStepInput { } export interface GetOrderByIdStepOutput { - order: OrderTypes.OrderDTO + order: OrderTypes.OrderDTO & { + customer: CustomerTypes.CustomerDTO + } } export const getOrderByIdStepId = "get-order-by-id"