-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Description
Package.json file
{
"name": "medusa",
"version": "0.0.1",
"description": "A starter for Medusa projects.",
"author": "Medusa (https://medusajs.com)",
"license": "MIT",
"keywords": [
"sqlite",
"postgres",
"typescript",
"ecommerce",
"headless",
"medusa"
],
"scripts": {
"build": "medusa build",
"seed": "medusa exec ./src/scripts/seed.ts",
"start": "medusa start",
"dev": "medusa develop",
"predeploy": "medusa db:migrate",
"test:integration:http": "TEST_TYPE=integration:http NODE_OPTIONS=--experimental-vm-modules jest --silent=false --runInBand --forceExit",
"test:integration:modules": "TEST_TYPE=integration:modules NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit",
"test:unit": "TEST_TYPE=unit NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit"
},
"dependencies": {
"@getbrevo/brevo": "^3.0.1",
"@medusajs/admin-sdk": "2.11.3",
"@medusajs/cli": "2.11.3",
"@medusajs/framework": "2.11.3",
"@medusajs/medusa": "2.11.3",
"@mikro-orm/core": "6.4.16",
"@mikro-orm/knex": "6.4.16",
"@mikro-orm/migrations": "6.4.16",
"@mikro-orm/postgresql": "6.4.16",
"@react-email/components": "0.3.1",
"awilix": "^8.0.1",
"pg": "^8.13.0"
},
"devDependencies": {
"@medusajs/test-utils": "2.11.3",
"@mikro-orm/cli": "6.4.16",
"@swc/core": "^1.7.28",
"@swc/jest": "^0.2.36",
"@types/jest": "^29.5.13",
"@types/node": "^20.0.0",
"@types/react": "^18.3.2",
"@types/react-dom": "^18.2.25",
"jest": "^29.7.0",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"ts-node": "^10.9.2",
"typescript": "^5.6.2",
"vite": "^5.2.11",
"yalc": "^1.0.0-pre.53"
},
"engines": {
"node": ">=20"
}
}Node.js version
v22.20.0
Database and its version
PostgresSQL 18.0
Operating system name and version
Mac OS Latest
Browser name
No response
What happended?
When an order is transferred a second time (A→B, then B→C), there are two issues:
Issue 1: Transfer Email Sent to Wrong Recipient
The order transfer confirmation email is sent to the original owner (A) instead of the current owner (B).
This happens because any code using order.email to determine the recipient will always get the original order email - it's never updated when ownership changes via transfer.
Issue 2: Admin Activity Log Shows Wrong Email
In the Medusa Admin, the Activity log for order transfers shows the original order email instead of the current customer's email. This is confusing when viewing transfer history after multiple transfers.
Code Example (demonstrating the fix)
// This is wrong - order.email is always the original email
const originalEmail = order.email || order.customer?.email
// This is correct - order.customer.email reflects the current owner
const currentOwnerEmail = order.customer?.email || order.emailFlow Demonstrating the Bug
-
Guest order placed with email
[email protected]order.email=[email protected]order.customer_id= null
-
First transfer requested (to [email protected])
- Email correctly sent to
[email protected]✓ - After acceptance:
order.customer_id= customerB's ID order.email= still[email protected](never updated)
- Email correctly sent to
-
Second transfer requested (to [email protected])
- Email incorrectly sent to
[email protected]✗ - Should be sent to
[email protected](current owner) - Admin Activity log shows
[email protected]instead of[email protected]✗
- Email incorrectly sent to
Expected behavior
-
Email recipient: The order transfer confirmation email should be sent to the current owner of the order (the linked customer's email, falling back to order.email for guest orders)
-
Activity log: The admin activity log should show the current customer's email, not the original order email
Actual behavior
-
The email is always sent to
order.email, which contains the original order email and is never updated during transfers -
The admin activity log displays
order.email(original) instead of the current owner's email
Actual behavior
. The email is always sent to order.email, which contains the original order email and is never updated during transfers
- The admin activity log displays
order.email(original) instead of the current owner's email
Reproduction
- Create a guest order with email
[email protected] - Request transfer to
[email protected]and accept it - Request transfer from customerA to
[email protected] - Observe:
- Transfer email is sent to
[email protected]instead of[email protected] - Admin activity log shows
[email protected]as the email
- Transfer email is sent to
Link to reproduction repo
N/A - This is a logic issue in how the recipient email is determined.
Link to reproduction repo
N/A