feat(fulfillment): List shipping options filtered by context anmd rules (#6507)
**What** Should be able to list the shipping options with or without a context, when a context is provided all the rules of the shipping options must be valid for the shipping options to be returned. FIXES CORE-1765
This commit is contained in:
1 parent
b13c669528
commit
ac829fc67f
7 files changed
+457
-320
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import { CreateShippingOptionDTO } from "@medusajs/types"
|
||||
|
||||
export function generateCreateShippingOptionsData({
|
||||
name,
|
||||
service_zone_id,
|
||||
shipping_profile_id,
|
||||
service_provider_id,
|
||||
price_type,
|
||||
rules,
|
||||
type,
|
||||
data,
|
||||
}: Omit<CreateShippingOptionDTO, "name" | "price_type" | "type"> & {
|
||||
price_type?: CreateShippingOptionDTO["price_type"]
|
||||
name?: string
|
||||
type?: CreateShippingOptionDTO["type"]
|
||||
}): Required<CreateShippingOptionDTO> {
|
||||
return {
|
||||
service_zone_id: service_zone_id,
|
||||
shipping_profile_id: shipping_profile_id,
|
||||
service_provider_id: service_provider_id,
|
||||
type: type ?? {
|
||||
code: "test-type",
|
||||
description: "test-description",
|
||||
label: "test-label",
|
||||
},
|
||||
data: data ?? {
|
||||
amount: 1000,
|
||||
},
|
||||
name: name ?? Math.random().toString(36).substring(7),
|
||||
price_type: price_type ?? "flat",
|
||||
rules: rules ?? [
|
||||
{
|
||||
attribute: "weight",
|
||||
operator: "eq",
|
||||
value: "test",
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user