What’s the goal here ?
In this part, we will extendShippingOption
to make them relevant to a store. In fact, each vendor must be able to input its own shipping options, giving the customer choices for each vendors.
We’ll also extend the behavior of ShippingProfile
to link them to a store too, because the shopping cart currently allows for multiple shipping methods, but the current implementation only allows for one per shipping profile, so we’ll create one by default for each store, allowing for multiple shipping methods for a single cart.
Note that shipping profiles are supposed to be created by admins in the current version (
1.2x.x
).ShippingOption
Extend the ShippingOption entity
As with our previous entities, we want aShippingOption
to be linked to a Store
src/models/shipping-option.ts
Update the Store entity
Adding aManyToOne
relationship above also means updating the Store
model:
src/models/store.ts
Create the ShippingOption migration
Once the entity and repository have been extended, we can now create our :src/migrations/...-add-shipping-option-store-id.ts
yarn build
command and then run the npx medusa migrations run
command, as for our previous migrations to make the changes in your database :

ShippingProfile
Extend the ShippingProfile entity
Once theShippingOption
entity has been fully extended, we also need to extend the ShippingProfile
entity, almost like copying and pasting what we’ve done above.
In the same way :
src/models/shipping-profile.ts
Update the Store entity
We update our Store entity to add the newshippingProfiles
property :
src/models/store.ts
Create the ShippingProfile migration
We can now create the migration file for theShippingProfile
migration to apply our changes to the database :
src/migrations/...-add-shipping-profile-store-id.ts

GitHub Branch
You can access the complete part’s code here.Next Steps
Next, we’ll look at the two services:ShippingProfileService
and ShippingOptionService
, and how/what we can override some of their functions. We’ll use the same reasoning as the ProductService
, where we made sure to fetch only the products associated with a Store or tie a new product to a specific store.