fix(core-flows): shipping options for cart (#9343)
FIXES: CC-536 Co-authored-by: Frane Polić <16856471+fPolic@users.noreply.github.com>
This commit is contained in:
co-authored by
Frane Polić
parent
74b3385a65
commit
19bc8d7f61
@@ -2,12 +2,15 @@ import { listShippingOptionsForCartWorkflow } from "@medusajs/core-flows"
|
||||
import { HttpTypes, ICartModuleService } from "@medusajs/framework/types"
|
||||
import { MedusaError, Modules } from "@medusajs/framework/utils"
|
||||
import { MedusaRequest, MedusaResponse } from "../../../types/routing"
|
||||
import { StoreGetShippingOptionsType } from "./validators"
|
||||
|
||||
export const GET = async (
|
||||
req: MedusaRequest<HttpTypes.StoreGetShippingOptionList>,
|
||||
res: MedusaResponse<HttpTypes.StoreShippingOptionListResponse>
|
||||
) => {
|
||||
const { cart_id } = req.filterableFields as { cart_id: string }
|
||||
const { cart_id, is_return } =
|
||||
req.filterableFields as StoreGetShippingOptionsType
|
||||
|
||||
if (!cart_id) {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.NOT_ALLOWED,
|
||||
@@ -34,6 +37,7 @@ export const GET = async (
|
||||
cart_id: cart.id,
|
||||
sales_channel_id: cart.sales_channel_id,
|
||||
currency_code: cart.currency_code,
|
||||
is_return: !!is_return,
|
||||
shipping_address: {
|
||||
city: cart.shipping_address?.city,
|
||||
country_code: cart.shipping_address?.country_code,
|
||||
|
||||
@@ -10,6 +10,7 @@ export const StoreGetShippingOptions = createFindParams({
|
||||
}).merge(
|
||||
z.object({
|
||||
cart_id: z.string(),
|
||||
is_return: z.boolean().optional(),
|
||||
$and: z.lazy(() => StoreGetShippingOptions.array()).optional(),
|
||||
$or: z.lazy(() => StoreGetShippingOptions.array()).optional(),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user