diff --git a/packages/core/core-flows/src/cart/workflows/list-shipping-options-for-cart.ts b/packages/core/core-flows/src/cart/workflows/list-shipping-options-for-cart.ts index c2a72e172e3fb..0f048364138d7 100644 --- a/packages/core/core-flows/src/cart/workflows/list-shipping-options-for-cart.ts +++ b/packages/core/core-flows/src/cart/workflows/list-shipping-options-for-cart.ts @@ -127,6 +127,8 @@ export const listShippingOptionsForCartWorkflow = createWorkflow( "rules.operator", "calculated_price.*", + "prices.*", + "prices.price_rules.*", ], variables: queryVariables, }).config({ name: "shipping-options-query" }) diff --git a/packages/core/types/src/http/fulfillment/store/index.ts b/packages/core/types/src/http/fulfillment/store/index.ts index 39e6c365c0d15..23a6e449e5cc8 100644 --- a/packages/core/types/src/http/fulfillment/store/index.ts +++ b/packages/core/types/src/http/fulfillment/store/index.ts @@ -1,4 +1,5 @@ import { ShippingOptionPriceType } from "../../../fulfillment" +import { StoreCalculatedPrice, StorePrice } from "../../pricing/store/entities" // TODO: The way the cart shipping options are listed now differs from most other endpoints as it is fetched in a workflow. // We should consider refactoring this to be more consistent with other endpoints. @@ -13,7 +14,7 @@ export interface StoreCartShippingOption { name: string /** * The type of the shipping option's price. `flat` means the price - * is fixed, whereas `calculated` means the price is calculated by the + * is fixed, whereas `calculated` means the price is calculated by the * associated fulfillment provider. */ price_type: ShippingOptionPriceType @@ -31,7 +32,7 @@ export interface StoreCartShippingOption { provider_id: string /** * The data useful for the fulfillment provider when handling the shipment and fulfillment. - * + * * Learn more in [this documentation](https://docs.medusajs.com/resources/commerce-modules/fulfillment/shipping-option#data-property). */ data: Record | null @@ -73,4 +74,14 @@ export interface StoreCartShippingOption { * The shipping option's amount. */ amount: number + + /** + * All the prices for this shipping option + */ + prices: StorePrice[] + + /** + * Calculated price for the shipping option + */ + calculated_price: StoreCalculatedPrice } diff --git a/packages/core/types/src/http/pricing/index.ts b/packages/core/types/src/http/pricing/index.ts index 26b8eb9dadfe8..3bd2bd2cc018f 100644 --- a/packages/core/types/src/http/pricing/index.ts +++ b/packages/core/types/src/http/pricing/index.ts @@ -1 +1,2 @@ export * from "./admin" +export * from "./store" diff --git a/packages/core/types/src/http/pricing/store/entities.ts b/packages/core/types/src/http/pricing/store/entities.ts new file mode 100644 index 0000000000000..6054e0f922e12 --- /dev/null +++ b/packages/core/types/src/http/pricing/store/entities.ts @@ -0,0 +1,56 @@ +import { PricingRuleOperatorValues } from "../../../pricing" +import { BaseCalculatedPriceSet } from "../common" + +export interface StorePrice { + /** + * The price's ID. + */ + id: string + /** + * The price's currency code. + * + * @example + * usd + */ + currency_code: string + /** + * The price's amount. + */ + amount: number + /** + * The minimum quantity that must be available in the cart for the price to be applied. + */ + min_quantity: number | null + /** + * The maximum quantity allowed to be available in the cart for the price to be applied. + */ + max_quantity: number | null + + /** + * The rules enabled to enable the current price + */ + price_rules?: StorePriceRule[] +} + +export interface StorePriceRule { + /** + * The ID of the price rule. + */ + id: string + /** + * The attribute of the price rule + */ + attribute: string + + /** + * The operator of the price rule + */ + operator: PricingRuleOperatorValues + + /** + * The value of the price rule. + */ + value: string +} + +export interface StoreCalculatedPrice extends BaseCalculatedPriceSet {} diff --git a/packages/core/types/src/http/pricing/store/index.ts b/packages/core/types/src/http/pricing/store/index.ts new file mode 100644 index 0000000000000..8270e0b265e19 --- /dev/null +++ b/packages/core/types/src/http/pricing/store/index.ts @@ -0,0 +1 @@ +export * from "./entities"