Class: ShippingProfileService
Provides layer to manipulate profiles.
Implements
Copy to Clipboard
Hierarchy
TransactionBaseService
Copy to Clipboard↳
ShippingProfileService
Copy to Clipboard
Constructors
constructor
• new ShippingProfileService(__namedParameters
Copy to Clipboard)
Parameters
Name | Type |
---|---|
__namedParameters Copy to Clipboard | InjectedDependencies Copy to Clipboard |
Overrides
TransactionBaseService.constructor
Defined in
medusa/src/services/shipping-profile.ts:45
Properties
__configModule__
• Protected
Copy to Clipboard Optional
Copy to Clipboard Readonly
Copy to Clipboard __configModule__: Record
Copy to Clipboard<string
Copy to Clipboard, unknown
Copy to Clipboard>
Inherited from
TransactionBaseService.__configModule__
Defined in
medusa/src/interfaces/transaction-base-service.ts:14
__container__
• Protected
Copy to Clipboard Readonly
Copy to Clipboard __container__: any
Copy to Clipboard
Inherited from
TransactionBaseService.__container__
Defined in
medusa/src/interfaces/transaction-base-service.ts:13
__moduleDeclaration__
• Protected
Copy to Clipboard Optional
Copy to Clipboard Readonly
Copy to Clipboard __moduleDeclaration__: Record
Copy to Clipboard<string
Copy to Clipboard, unknown
Copy to Clipboard>
Inherited from
TransactionBaseService.__moduleDeclaration__
Defined in
medusa/src/interfaces/transaction-base-service.ts:15
customShippingOptionService_
• Protected
Copy to Clipboard Readonly
Copy to Clipboard customShippingOptionService_: CustomShippingOptionService
Copy to Clipboard
Defined in
medusa/src/services/shipping-profile.ts:40
manager_
• Protected
Copy to Clipboard manager_: EntityManager
Copy to Clipboard
Inherited from
TransactionBaseService.manager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:5
productRepository_
• Protected
Copy to Clipboard Readonly
Copy to Clipboard productRepository_: Repository
Copy to Clipboard<Product
Copy to Clipboard> & { _applyCategoriesQuery
Copy to Clipboard: (qb
Copy to Clipboard: SelectQueryBuilder
Copy to Clipboard<Product
Copy to Clipboard>, __namedParameters
Copy to Clipboard: Object
Copy to Clipboard) => SelectQueryBuilder
Copy to Clipboard<Product
Copy to Clipboard> ; _findWithRelations
Copy to Clipboard: (__namedParameters
Copy to Clipboard: { idsOrOptionsWithoutRelations
Copy to Clipboard: string
Copy to Clipboard[] | FindWithoutRelationsOptions
Copy to Clipboard ; relations
Copy to Clipboard: string
Copy to Clipboard[] ; shouldCount
Copy to Clipboard: boolean
Copy to Clipboard ; withDeleted
Copy to Clipboard: boolean
Copy to Clipboard }) => Promise
Copy to Clipboard<[Product
Copy to Clipboard[], number
Copy to Clipboard]> ; bulkAddToCollection
Copy to Clipboard: (productIds
Copy to Clipboard: string
Copy to Clipboard[], collectionId
Copy to Clipboard: string
Copy to Clipboard) => Promise
Copy to Clipboard<Product
Copy to Clipboard[]> ; bulkRemoveFromCollection
Copy to Clipboard: (productIds
Copy to Clipboard: string
Copy to Clipboard[], collectionId
Copy to Clipboard: string
Copy to Clipboard) => Promise
Copy to Clipboard<Product
Copy to Clipboard[]> ; findOneWithRelations
Copy to Clipboard: (relations
Copy to Clipboard: string
Copy to Clipboard[], optionsWithoutRelations
Copy to Clipboard: FindWithoutRelationsOptions
Copy to Clipboard) => Promise
Copy to Clipboard<Product
Copy to Clipboard> ; findWithRelations
Copy to Clipboard: (relations
Copy to Clipboard: string
Copy to Clipboard[], idsOrOptionsWithoutRelations
Copy to Clipboard: string
Copy to Clipboard[] | FindWithoutRelationsOptions
Copy to Clipboard, withDeleted
Copy to Clipboard: boolean
Copy to Clipboard) => Promise
Copy to Clipboard<Product
Copy to Clipboard[]> ; findWithRelationsAndCount
Copy to Clipboard: (relations
Copy to Clipboard: string
Copy to Clipboard[], idsOrOptionsWithoutRelations
Copy to Clipboard: FindWithoutRelationsOptions
Copy to Clipboard) => Promise
Copy to Clipboard<[Product
Copy to Clipboard[], number
Copy to Clipboard]> ; getFreeTextSearchResultsAndCount
Copy to Clipboard: (q
Copy to Clipboard: string
Copy to Clipboard, options
Copy to Clipboard: FindWithoutRelationsOptions
Copy to Clipboard, relations
Copy to Clipboard: string
Copy to Clipboard[]) => Promise
Copy to Clipboard<[Product
Copy to Clipboard[], number
Copy to Clipboard]> ; isProductInSalesChannels
Copy to Clipboard: (id
Copy to Clipboard: string
Copy to Clipboard, salesChannelIds
Copy to Clipboard: string
Copy to Clipboard[]) => Promise
Copy to Clipboard<boolean
Copy to Clipboard> ; queryProducts
Copy to Clipboard: (optionsWithoutRelations
Copy to Clipboard: FindWithoutRelationsOptions
Copy to Clipboard, shouldCount
Copy to Clipboard: boolean
Copy to Clipboard) => Promise
Copy to Clipboard<[Product
Copy to Clipboard[], number
Copy to Clipboard]> ; queryProductsWithIds
Copy to Clipboard: (__namedParameters
Copy to Clipboard: { entityIds
Copy to Clipboard: string
Copy to Clipboard[] ; groupedRelations
Copy to Clipboard: { [toplevel: string]
Copy to Clipboard: string
Copy to Clipboard[]; } ; order?
Copy to Clipboard: { [column: string]
Copy to Clipboard: "ASC"
Copy to Clipboard | "DESC"
Copy to Clipboard; } ; select?
Copy to Clipboard: keyof Product
Copy to Clipboard[] ; where?
Copy to Clipboard: FindOptionsWhere
Copy to Clipboard<Product
Copy to Clipboard> ; withDeleted?
Copy to Clipboard: boolean
Copy to Clipboard }) => Promise
Copy to Clipboard<Product
Copy to Clipboard[]> ; upsertShippingProfile
Copy to Clipboard: (productIds
Copy to Clipboard: string
Copy to Clipboard[], shippingProfileId
Copy to Clipboard: string
Copy to Clipboard) => Promise
Copy to Clipboard<Product
Copy to Clipboard[]> }
Defined in
medusa/src/services/shipping-profile.ts:43
productService_
• Protected
Copy to Clipboard Readonly
Copy to Clipboard productService_: ProductService
Copy to Clipboard
Defined in
medusa/src/services/shipping-profile.ts:38
shippingOptionService_
• Protected
Copy to Clipboard Readonly
Copy to Clipboard shippingOptionService_: ShippingOptionService
Copy to Clipboard
Defined in
medusa/src/services/shipping-profile.ts:39
shippingProfileRepository_
• Protected
Copy to Clipboard Readonly
Copy to Clipboard shippingProfileRepository_: Repository
Copy to Clipboard<ShippingProfile
Copy to Clipboard>
Defined in
medusa/src/services/shipping-profile.ts:42
transactionManager_
• Protected
Copy to Clipboard transactionManager_: undefined
Copy to Clipboard | EntityManager
Copy to Clipboard
Inherited from
TransactionBaseService.transactionManager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:6
Accessors
activeManager_
• Protected
Copy to Clipboard get
Copy to Clipboard activeManager_(): EntityManager
Copy to Clipboard
Returns
EntityManager
Copy to Clipboard
Inherited from
TransactionBaseService.activeManager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:8
Methods
addProduct
▸ addProduct(profileId
Copy to Clipboard, productId
Copy to Clipboard): Promise
Copy to Clipboard<ShippingProfile
Copy to Clipboard>
Adds a product of an array of products to the profile.
Parameters
Name | Type | Description |
---|---|---|
profileId Copy to Clipboard | string Copy to Clipboard | the profile to add the products to. |
productId Copy to Clipboard | string Copy to Clipboard | string Copy to Clipboard[] | the ID of the product or multiple products to add. |
Returns
Promise
Copy to Clipboard<ShippingProfile
Copy to Clipboard>
the result of update
Defined in
medusa/src/services/shipping-profile.ts:355
addShippingOption
▸ addShippingOption(profileId
Copy to Clipboard, optionId
Copy to Clipboard): Promise
Copy to Clipboard<ShippingProfile
Copy to Clipboard>
Adds a shipping option to the profile. The shipping option can be used to fulfill the products in the products field.
Parameters
Name | Type | Description |
---|---|---|
profileId Copy to Clipboard | string Copy to Clipboard | the profile to apply the shipping option to |
optionId Copy to Clipboard | string Copy to Clipboard | string Copy to Clipboard[] | the ID of the option or multiple options to add to the profile |
Returns
Promise
Copy to Clipboard<ShippingProfile
Copy to Clipboard>
the result of the model update operation
Defined in
medusa/src/services/shipping-profile.ts:385
atomicPhase_
▸ Protected
Copy to Clipboard atomicPhase_<TResult
Copy to Clipboard, TError
Copy to Clipboard>(work
Copy to Clipboard, isolationOrErrorHandler?
Copy to Clipboard, maybeErrorHandlerOrDontFail?
Copy to Clipboard): Promise
Copy to Clipboard<TResult
Copy to Clipboard>
Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created.
Type parameters
Name |
---|
TResult Copy to Clipboard |
TError Copy to Clipboard |
Parameters
Name | Type | Description |
---|---|---|
work Copy to Clipboard | (transactionManager Copy to Clipboard: EntityManager Copy to Clipboard) => Promise Copy to Clipboard<TResult Copy to Clipboard> | the transactional work to be done |
isolationOrErrorHandler? Copy to Clipboard | IsolationLevel Copy to Clipboard | (error Copy to Clipboard: TError Copy to Clipboard) => Promise Copy to Clipboard<void Copy to Clipboard | TResult Copy to Clipboard> | the isolation level to be used for the work. |
maybeErrorHandlerOrDontFail? Copy to Clipboard | (error Copy to Clipboard: TError Copy to Clipboard) => Promise Copy to Clipboard<void Copy to Clipboard | TResult Copy to Clipboard> | Potential error handler |
Returns
Promise
Copy to Clipboard<TResult
Copy to Clipboard>
the result of the transactional work
Inherited from
TransactionBaseService.atomicPhase_
Defined in
medusa/src/interfaces/transaction-base-service.ts:56
create
▸ create(profile
Copy to Clipboard): Promise
Copy to Clipboard<ShippingProfile
Copy to Clipboard>
Creates a new shipping profile.
Parameters
Name | Type | Description |
---|---|---|
profile Copy to Clipboard | CreateShippingProfile Copy to Clipboard | the shipping profile to create from |
Returns
Promise
Copy to Clipboard<ShippingProfile
Copy to Clipboard>
the result of the create operation
Defined in
medusa/src/services/shipping-profile.ts:249
createDefault
▸ createDefault(): Promise
Copy to Clipboard<ShippingProfile
Copy to Clipboard>
Creates a default shipping profile, if this does not already exist.
Returns
Promise
Copy to Clipboard<ShippingProfile
Copy to Clipboard>
the shipping profile
Defined in
medusa/src/services/shipping-profile.ts:179
createGiftCardDefault
▸ createGiftCardDefault(): Promise
Copy to Clipboard<ShippingProfile
Copy to Clipboard>
Creates a default shipping profile, for gift cards if unless it already exists.
Returns
Promise
Copy to Clipboard<ShippingProfile
Copy to Clipboard>
the shipping profile
Defined in
medusa/src/services/shipping-profile.ts:223
delete
▸ delete(profileId
Copy to Clipboard): Promise
Copy to Clipboard<void
Copy to Clipboard>
Deletes a profile with a given profile id.
Parameters
Name | Type | Description |
---|---|---|
profileId Copy to Clipboard | string Copy to Clipboard | the id of the profile to delete. Must be castable as an ObjectId |
Returns
Promise
Copy to Clipboard<void
Copy to Clipboard>
the result of the delete operation.
Defined in
medusa/src/services/shipping-profile.ts:330
fetchCartOptions
▸ fetchCartOptions(cart
Copy to Clipboard): Promise
Copy to Clipboard<ShippingOption
Copy to Clipboard[]>
Finds all the shipping profiles that cover the products in a cart, and validates all options that are available for the cart.
Parameters
Name | Type | Description |
---|---|---|
cart Copy to Clipboard | any Copy to Clipboard | the cart object to find shipping options for |
Returns
Promise
Copy to Clipboard<ShippingOption
Copy to Clipboard[]>
a list of the available shipping options
Defined in
medusa/src/services/shipping-profile.ts:415
fetchOptionsByProductIds
▸ fetchOptionsByProductIds(productIds
Copy to Clipboard, filter
Copy to Clipboard): Promise
Copy to Clipboard<ShippingOption
Copy to Clipboard[]>
Parameters
Name | Type |
---|---|
productIds Copy to Clipboard | string Copy to Clipboard[] |
filter Copy to Clipboard | Selector Copy to Clipboard<ShippingOption Copy to Clipboard> |
Returns
Promise
Copy to Clipboard<ShippingOption
Copy to Clipboard[]>
Defined in
medusa/src/services/shipping-profile.ts:82
getProfilesInCart
▸ Protected
Copy to Clipboard getProfilesInCart(cart
Copy to Clipboard): string
Copy to Clipboard[]
Returns a list of all the productIds in the cart.
Parameters
Name | Type | Description |
---|---|---|
cart Copy to Clipboard | Cart Copy to Clipboard | the cart to extract products from |
Returns
string
Copy to Clipboard[]
a list of product ids
Defined in
medusa/src/services/shipping-profile.ts:481
list
▸ list(selector?
Copy to Clipboard, config?
Copy to Clipboard): Promise
Copy to Clipboard<ShippingProfile
Copy to Clipboard[]>
Parameters
Name | Type | Description |
---|---|---|
selector Copy to Clipboard | Selector Copy to Clipboard<ShippingProfile Copy to Clipboard> | the query object for find |
config Copy to Clipboard | FindConfig Copy to Clipboard<ShippingProfile Copy to Clipboard> | the config object for find |
Returns
Promise
Copy to Clipboard<ShippingProfile
Copy to Clipboard[]>
the result of the find operation
Defined in
medusa/src/services/shipping-profile.ts:67
retrieve
▸ retrieve(profileId
Copy to Clipboard, options?
Copy to Clipboard): Promise
Copy to Clipboard<ShippingProfile
Copy to Clipboard>
Gets a profile by id. Throws in case of DB Error and if profile was not found.
Parameters
Name | Type | Description |
---|---|---|
profileId Copy to Clipboard | string Copy to Clipboard | the id of the profile to get. |
options Copy to Clipboard | FindConfig Copy to Clipboard<ShippingProfile Copy to Clipboard> | options opf the query. |
Returns
Promise
Copy to Clipboard<ShippingProfile
Copy to Clipboard>
the profile document.
Defined in
medusa/src/services/shipping-profile.ts:134
retrieveDefault
▸ retrieveDefault(): Promise
Copy to Clipboard<null
Copy to Clipboard | ShippingProfile
Copy to Clipboard>
Returns
Promise
Copy to Clipboard<null
Copy to Clipboard | ShippingProfile
Copy to Clipboard>
Defined in
medusa/src/services/shipping-profile.ts:163
retrieveGiftCardDefault
▸ retrieveGiftCardDefault(): Promise
Copy to Clipboard<null
Copy to Clipboard | ShippingProfile
Copy to Clipboard>
Retrieves the default gift card profile
Returns
Promise
Copy to Clipboard<null
Copy to Clipboard | ShippingProfile
Copy to Clipboard>
the shipping profile for gift cards
Defined in
medusa/src/services/shipping-profile.ts:206
shouldRetryTransaction_
▸ Protected
Copy to Clipboard shouldRetryTransaction_(err
Copy to Clipboard): boolean
Copy to Clipboard
Parameters
Name | Type |
---|---|
err Copy to Clipboard | Record Copy to Clipboard<string Copy to Clipboard, unknown Copy to Clipboard> | { code Copy to Clipboard: string Copy to Clipboard } |
Returns
boolean
Copy to Clipboard
Inherited from
TransactionBaseService.shouldRetryTransaction_
Defined in
medusa/src/interfaces/transaction-base-service.ts:37
update
▸ update(profileId
Copy to Clipboard, update
Copy to Clipboard): Promise
Copy to Clipboard<ShippingProfile
Copy to Clipboard>
Updates a profile. Metadata updates and product updates should use
dedicated methods, e.g. setMetadata
Copy to Clipboard, addProduct
Copy to Clipboard, etc. The function
will throw errors if metadata or product updates are attempted.
Parameters
Name | Type | Description |
---|---|---|
profileId Copy to Clipboard | string Copy to Clipboard | the id of the profile. Must be a string that can be casted to an ObjectId |
update Copy to Clipboard | UpdateShippingProfile Copy to Clipboard | an object with the update values. |
Returns
Promise
Copy to Clipboard<ShippingProfile
Copy to Clipboard>
resolves to the update result.
Defined in
medusa/src/services/shipping-profile.ts:284
withTransaction
▸ withTransaction(transactionManager?
Copy to Clipboard): ShippingProfileService
Copy to Clipboard
Parameters
Name | Type |
---|---|
transactionManager? Copy to Clipboard | EntityManager Copy to Clipboard |
Returns
ShippingProfileService
Copy to Clipboard
Inherited from
TransactionBaseService.withTransaction