medusajs / medusa

Building blocks for digital commerce
https://medusajs.com
MIT License
24.76k stars 2.44k forks source link

Metadata is not being saved when creating draft orders via API #9136

Open ederwii opened 1 week ago

ederwii commented 1 week ago

Bug report

Describe the bug

While creating a new draft order using the medusajs client, the draft order is created but the metadata is not saved to the database.

System information

Medusa version (including plugins): "@medusajs/medusa": "^1.20.7", Node.js version: 22 Database: postgresql Operating system: windows/mac/ubuntu Browser (if relevant):

Steps to reproduce the behavior

  1. Using the medusajs api client already configured with a valid API token, attempt to create a valid draft order, with valid metadata
  2. Using the medusajs api client already configured with a valid API token, retrieve the brand new draft order.

Expected behavior

Metadata should be populated with the sent data

Screenshots

If applicable, add screenshots to help explain your problem

Code snippets

If applicable, add code samples to help explain your problem

Additional context

I also checked on the database, the metadata is blank there. I manually added metadata to a draft order and the retrieve gets it, so the problem seems to be in the create action.

srindom commented 1 week ago

Looks like we are not picking the metadata in the draft order service, here: https://github.com/medusajs/medusa/blob/74885620a8e2fdb255053d5dc3c05ab139074b31/packages/medusa/src/services/draft-order.ts#L274-L295

If someone is up for creating a PR that adds the metadata, we will be happy to accept it.