feat: Completely revamp the pricing module (#7852)
* feat: Completely revamp the pricing module * chore: Update all places to the new pricing interfaces * fix: Remove unnecessary join to itself * chore: Add data migration for existing users * fix: Apply the correct index to price rule
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
import { IPricingModuleService } from "@medusajs/types"
|
||||
|
||||
export const createDefaultRuleTypes = async (container) => {
|
||||
const pricingModuleService: IPricingModuleService = container.resolve(
|
||||
"pricingModuleService"
|
||||
)
|
||||
|
||||
return await pricingModuleService.createRuleTypes([
|
||||
{
|
||||
name: "region_id",
|
||||
rule_attribute: "region_id",
|
||||
},
|
||||
{
|
||||
name: "customer_group_id",
|
||||
rule_attribute: "customer_group_id",
|
||||
},
|
||||
])
|
||||
}
|
||||
@@ -13,18 +13,14 @@ const defaultPrices = [
|
||||
},
|
||||
]
|
||||
|
||||
const defaultPriceSetRules = [{ rule_attribute: "region_id" }]
|
||||
|
||||
export const createVariantPriceSet = async ({
|
||||
container,
|
||||
variantId,
|
||||
prices = defaultPrices,
|
||||
rules = defaultPriceSetRules,
|
||||
}: {
|
||||
container: MedusaContainer
|
||||
variantId: string
|
||||
prices?: CreatePriceSetDTO["prices"]
|
||||
rules?: CreatePriceSetDTO["rules"]
|
||||
}): Promise<PriceSetDTO> => {
|
||||
const remoteLink = container.resolve("remoteLink")
|
||||
const pricingModuleService: IPricingModuleService = container.resolve(
|
||||
@@ -32,7 +28,6 @@ export const createVariantPriceSet = async ({
|
||||
)
|
||||
|
||||
const priceSet = await pricingModuleService.createPriceSets({
|
||||
rules,
|
||||
prices,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user