fix(): update cart line item route fetching (#13477)

**What**
Remove cart fetching before workflow which fetch the cart as well
This commit is contained in:
Adrien de Peretti
2025-09-11 10:12:13 +00:00
committed by GitHub
parent d828005354
commit 29dca1ca48
3 changed files with 15 additions and 30 deletions
@@ -2,10 +2,9 @@ import {
deleteLineItemsWorkflowId,
updateLineItemInCartWorkflowId,
} from "@medusajs/core-flows"
import { prepareListQuery } from "@medusajs/framework"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { HttpTypes } from "@medusajs/framework/types"
import { MedusaError, Modules } from "@medusajs/framework/utils"
import { Modules } from "@medusajs/framework/utils"
import { refetchCart } from "../../../helpers"
import { StoreUpdateCartLineItemType } from "../../../validators"
@@ -13,38 +12,11 @@ export const POST = async (
req: MedusaRequest<StoreUpdateCartLineItemType>,
res: MedusaResponse<HttpTypes.StoreCartResponse>
) => {
// TODO: Move this to the workflow when the query to line item is fixed
const cart = await refetchCart(
req.params.id,
req.scope,
prepareListQuery(
{},
{
defaults: [
"id",
"region_id",
"customer_id",
"sales_channel_id",
"currency_code",
"*items",
],
}
).remoteQueryConfig.fields
)
const item = cart.items?.find((i) => i.id === req.params.line_id)
if (!item) {
throw new MedusaError(
MedusaError.Types.NOT_FOUND,
`Line item with id: ${req.params.line_id} was not found`
)
}
const we = req.scope.resolve(Modules.WORKFLOW_ENGINE)
await we.run(updateLineItemInCartWorkflowId, {
input: {
cart_id: req.params.id,
item_id: item.id,
item_id: req.params.line_id,
update: req.validatedBody,
},
transactionId: "cart-update-item-" + req.params.id,