Skip to content

Commit

Permalink
fix line item service
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien2p committed Jan 2, 2024
1 parent 8859da5 commit b5c9e04
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions packages/medusa/src/services/line-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,15 +505,17 @@ class LineItemService extends TransactionBaseService {
this.lineItemRepository_
)

return (await lineItemRepository
.find({ where: { id: In(ids) } })
.then(
async (lineItems) =>
lineItems.length && lineItemRepository.remove(lineItems)
)
.then((lineItems) => {
return Array.isArray(id) ? lineItems : lineItems[0]
})) as TResult
const lineItems = await lineItemRepository.find({
where: { id: In(ids) },
})

let result
if (lineItems.length) {
await lineItemRepository.remove(lineItems)
result = Array.isArray(id) ? lineItems : lineItems[0]
}

return result as TResult
}
)
}
Expand Down

0 comments on commit b5c9e04

Please sign in to comment.