feat: Add exchange return shipping (#8108)
* wip * finalize tests * feat: Add exchange return shipping * add shipping to preview * test input * move utils and ignore already inserted shipping method * use custom price --------- Co-authored-by: Carlos R. L. Rodrigues <rodrigolr@gmail.com>
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
import { createReturnShippingMethodWorkflow } from "@medusajs/core-flows"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
remoteQueryObjectFromString,
|
||||
} from "@medusajs/utils"
|
||||
import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
@@ -15,26 +11,13 @@ export const POST = async (
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
await createReturnShippingMethodWorkflow(req.scope).run({
|
||||
const { result: orderPreview } = await createReturnShippingMethodWorkflow(
|
||||
req.scope
|
||||
).run({
|
||||
input: { ...req.validatedBody, return_id: id },
|
||||
})
|
||||
|
||||
const queryObject = remoteQueryObjectFromString({
|
||||
entryPoint: "return",
|
||||
variables: {
|
||||
id,
|
||||
filters: {
|
||||
...req.filterableFields,
|
||||
},
|
||||
},
|
||||
fields: req.remoteQueryConfig.fields,
|
||||
})
|
||||
|
||||
const [orderReturn] = await remoteQuery(queryObject)
|
||||
|
||||
res.json({
|
||||
return: orderReturn,
|
||||
order: orderPreview,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user