Skip to content
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

Metadata not included with Order query #7398

Closed
x8BitRain opened this issue May 22, 2024 · 3 comments
Closed

Metadata not included with Order query #7398

x8BitRain opened this issue May 22, 2024 · 3 comments

Comments

@x8BitRain
Copy link

Bug report

Describe the bug

If I query an existing order or list the current customer's orders with metadata attached to it, it does not get included in the query response via HTTP or medusaJS client. All related model data does though, region, payment, variants, customer etc, include metadata except the Order object.

I have a custom API endpoint that creates orders from carts with orderService.createFromCart():

export async function POST(
  req: MedusaRequest,
  res: MedusaResponse,
): Promise<void> {
  // This is here to bypass the entire Medusa order process and create an order directly from a cart for PoC purposes.

  const orderService = req.scope.resolve('orderService') as OrderService;
  const { cart_id } = req.body as ApiNewOrderRequest;

  try {
    const newOrder = await orderService.createFromCart(cart_id);

    res.status(200).json(newOrder);
  } catch (error) {
    res.status(500).json({ message: error.message });
  }
}

I then can update the metadata with:

const newOrder = await orderService.update(order_id, {
    metadata: {
        status: status,
    },
});

The orders do show metadata in the admin panel but when querying with the medusa-js client:

medusa.customers.listOrders();

or

medusa.orders.retrieve('order_01HYFPV5T711ZRHFJSK348P6BB')

the metadata is not included in the response.

System information

Medusa version (including plugins):

    "@medusajs/admin": "^7.1.14",
    "@medusajs/cache-inmemory": "latest",
    "@medusajs/cache-redis": "^1.9.1",
    "@medusajs/event-bus-local": "latest",
    "@medusajs/event-bus-redis": "^1.8.13",
    "@medusajs/file-local": "latest",
    "@medusajs/medusa": "^1.20.6",
    "@medusajs/product": "^0.3.12",

Node.js version: v20.12.0
Database: Postgres 16
Operating system: macos
Browser (if relevant): latest chrome

Steps to reproduce the behavior

medusa-no-metadata-on-orders.mp4

Expected behavior

metadata should be included with Order queries made via medusa-js client

Additional context

If I make my own endpoint with orderService.retrieve() then it returns the data with metadata attached:

image

export async function POST(
  req: MedusaRequest,
  res: MedusaResponse,
): Promise<void> {
  // This is here to update the order status manually for PoC purposes.\
  const orderService = req.scope.resolve('orderService') as OrderService;
  const { order_id } = req.body as ApiNewOrderUpdateRequest;

  try {
    const newOrder = await orderService.retrieve(order_id);

    res.status(200).json(newOrder);
  } catch (error) {
    res.status(500).json({ message: error.message });
  }
}
Copy link
Contributor

github-actions bot commented Oct 8, 2024

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 3 days.

@github-actions github-actions bot added the Stale label Oct 8, 2024
Copy link
Contributor

This issue was closed because it has been stalled for 3 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 13, 2024
@oz-verum
Copy link

oz-verum commented Nov 6, 2024

Hi guys, it still exists, no metadata in medusa.customers.listOrders(); but as mentioned in your doc it's required, please add the missed property, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants