Build your own marketplace from scratch using Medusa
ShippingOption
and ShippingProfile
entities, we can start integrating new features into our services.
ShippingOption
and ShippingProfile
services, so that vendors can only access their own shipping options/profiles, and create a shipping option/profile for their store only.
We’ll also look at the concept of loaders, to create a default ShippingProfile
file for each store.
ShippingOptionService
file :
ShippingOptionService.list
functionShippingOptionService.list
function and the ShippingOptionService.listAndCount
function:
ShippingOptionService.create
functionShippingOptionService.create
function and the CreateShippingOptionInput
type to allow for a store_id
property :
ShippingOptionService.validateCartOption
validateCartOption
function, which validates a ShippingOption for a Cart before saving it in the Cart. Here, we’re going to make sure that a chosen shipping option, has one or more products that belongs to the same store :
ShippingProfileService.list
ShippingProfileService.create
store_id
:
ShippingProfile.retrieveDefault
functionShippingProfile.createDefaultForStore
functionthis.atomicPhase_
) , so that in the case of an error throwed when creating a user (for example, an email already in use), no event is sent and it will rollback changes.
src/loaders/create-defaults-shipping-profiles.ts
folder :
StoreService
UserService