1 export const metadata = {
2 title: `Transfer Order to Guest Customer`,
3 }
4
5 # {metadata.title}
6
7 <Note>
8
9 This feature is available since Medusa [v2.18.0](https://github.com/medusajs/medusa/releases/tag/v2.18.0).
10
11 </Note>
12
13 In this guide, you'll learn how Medusa handles transferring an order to a guest customer.
14
15 ## Overview
16
17 An admin user can transfer an order from its current customer to a guest customer identified by email. Unlike the request order transfer flow, this transfer is applied immediately without requiring the recipient to accept it.
18
19 If no customer exists with the given email address, Medusa creates a new guest customer. The transfer can only be made to guest (non-registered) customers.
20
21 ---
22
23 ## Transfer Order to Guest Workflow
24
25 The transfer is handled by the `transferOrderToGuestWorkflow`, which is executed by the [Transfer Order to Guest API route](https://docs.medusajs.com/api/admin/orders/transfer-to-guest).
26
27 You can also use this workflow in your customizations:
28
29 ```ts title="src/workflows/transfer-to-guest.ts"
30 import { transferOrderToGuestWorkflow } from "@medusajs/medusa/core-flows"
31
32 const { result } = await transferOrderToGuestWorkflow(container)
33 .run({
34 input: {
35 order_id: "order_123",
36 email: "customer@example.com",
37 logged_in_user: "user_123",
38 },
39 })
40 ```
41
42 ### Input
43
44 The workflow accepts the following input:
45
46 - `order_id`: The ID of the order to transfer.
47 - `email`: The email of the guest customer to transfer the order to. If no customer exists with this email, a guest customer is created.
48 - `logged_in_user`: The ID of the admin user requesting the transfer.
49 - `description` (optional): Details of the transfer.
50 - `internal_note` (optional): A note visible to admin users only.
51
52 ### Validation
53
54 Before applying the transfer, the workflow validates that:
55
56 - The order is not cancelled.
57 - The resolved customer is not the same as the order's current customer.
58 - The resolved customer is a guest customer. Transfers to registered customer accounts are not allowed.
59
60 ---
61
62 ## Difference from Request Order Transfer Workflow
63
64 The `transferOrderToGuestWorkflow` is intended for admin users and applies the transfer immediately.
65
66 The `requestOrderTransferWorkflow`, on the other hand, sends a transfer request that the recipient customer must accept before the transfer is applied. Use that workflow when transferring an order to a registered customer account.