Files
medusa-store/integration-tests/helpers/seed-storefront-defaults.ts
Stevche Radevski e8d6025374 Add support for tax inclusivity to region and store (#7808)
This also includes rework of the currency model for the Store module.

This change is breaking as existing stores won't have any supported currencies set, so users would need to go to the store settings again and choose the supported currencies there.
2024-06-24 15:25:44 +00:00

42 lines
1.0 KiB
TypeScript

import { createDefaultsWorkflow } from "@medusajs/core-flows"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
import {
IRegionModuleService,
IStoreModuleService,
MedusaContainer,
} from "@medusajs/types"
export const seedStorefrontDefaults = async (
container: MedusaContainer,
defaultCurrency: string = "usd"
) => {
const regionModule: IRegionModuleService = container.resolve(
ModuleRegistrationName.REGION
)
const storeModule: IStoreModuleService = container.resolve(
ModuleRegistrationName.STORE
)
// Creates the stores & default sales channel
await createDefaultsWorkflow(container).run()
const region = await regionModule.createRegions({
name: "Default Region",
currency_code: defaultCurrency,
})
let [store] = await storeModule.listStores({})
store = await storeModule.updateStores(store.id, {
default_region_id: region.id,
supported_currencies: [
{ currency_code: region.currency_code, is_default: true },
],
})
return {
region,
store,
}
}