#Allow passing currency_code when fetching *items.variant.calculated_price via SDK

7 messages · Page 1 of 1 (latest)

candid rampart
#

Hey everyone, I’m hitting an issue when trying to fetch items.variant.calculated_price for my orders via the Store API.

https://github.com/medusajs/nextjs-starter-medusa/blob/main/src/lib/data/orders.ts

// src/lib/data/orders.ts return sdk.client.fetch<HttpTypes.StoreOrderListResponse>(/store/orders, { method: "GET", query: { limit, offset, order: "-created_at", fields: "*items.variant.calculated_price,*items,+items.metadata,*items.variant,*items.product", ...filters, }, headers, next, cache: "force-cache", }) .then(({ orders }) => orders) .catch((err) => medusaError(err))

I’m getting this error:
Error setting up the request: Method calculatePrices requires currency_code in the pricing context

What’s the recommended way to pass currency_code (and/or region_id) when using the JS-SDK’s .fetch() call so that calculated_price can be returned successfully?

Thanks in advance! 🙏

GitHub

A performant frontend ecommerce starter template with Next.js 15 and Medusa V2. - medusajs/nextjs-starter-medusa

candid rampart
#

any recommendations?

silver heath
candid rampart
#

@silver heath Will it work with Storefront (Next.js)?

silver heath
#

the storefront starter already does this somewhere

candid rampart
silver heath