-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Cart metadata does not get assigned to order metadata on order completion #10629
Comments
Hi! I am facing the same issue. Just in case the desired flow from the Medusa team isn't automatically copy the metadata from the cart to the order once placed, I also tried to update the order metadata with no luck. For me at least, it would be extreme useful that the cart's metadata is copied automatically to the order once placed. This is the other thing I was trying:
After that, I cannot see any metadata into the order, neither in the Admin UI nor in the database itself. Every metadata in the order is just Each call I made through the SDK is returning ok as expected, the initial metadata I send is also ok. Here's my code (collapsed for readability) Codeimport Medusa from "@medusajs/js-sdk";
const adminSdk = new Medusa({
baseUrl: MEDUSA_BACKEND_URL,
debug: process.env.NODE_ENV === "development",
apiKey: process.env.MEDUSA_ADMIN_API_KEY,
});
export async function updateOrderWithMetadata(
orderId: string,
metadata: Record<string, unknown>
) {
try {
const orderEditInitiated = await initiateOrderEdit(orderId, metadata).catch(
(error) => {
console.error("ORDER_EDIT_INITIATED_ERROR", error);
throw error;
}
);
console.log("ORDER_EDIT_INITIATED", orderEditInitiated);
const orderEditRequested = await requestOrderEdit(orderId).catch(
(error) => {
console.error("ORDER_EDIT_REQUESTED", error);
throw error;
}
);
console.log("ORDER_EDIT_REQUESTED", orderEditRequested);
const orderEditConfirmed = await confirmOrderEdit(orderId).catch(
(error) => {
console.error("ORDER_EDIT_CONFIRMED", error);
throw error;
}
);
console.log("ORDER_EDIT_CONFIRMED", orderEditConfirmed);
} catch (error) {
throw error;
}
}
async function initiateOrderEdit(
orderId: string,
metadata: Record<string, unknown>
) {
const { order_change } = await adminSdk.admin.orderEdit.initiateRequest({
order_id: orderId,
metadata,
});
return order_change;
}
async function requestOrderEdit(orderEditId: string) {
const { order_preview } = await adminSdk.admin.orderEdit.request(orderEditId);
return order_preview;
}
async function confirmOrderEdit(orderEditId: string) {
const { order_preview } = await adminSdk.admin.orderEdit.confirm(orderEditId);
return order_preview;
} SDK Version I am using: "@medusajs/js-sdk": "2.1.2" |
@olivermrbl Hi! I thought this was fixed with #10651 but I've been testing locally with everything updated to 2.1.3, no luck. Can you confirm this? Also, is there a way to send metadata to an order? If we could just copy the metadata from the cart once complete, it would be awesome. Thanks in advance! |
Package.json file
Node.js version
v22.11.0
Database and its version
PostgreSQL 16.2
Operating system name and version
MacOS Sonoma 14.6.1
Browser name
N/A
What happended?
Even though the cart metadata should be assigned to the order metadata field, this doesn't happen.
Expected behavior
The metadata of a cart should automatically transfer to the order.
Actual behavior
The order metadata is always null.
Link to reproduction repo
N/A
The text was updated successfully, but these errors were encountered: