ShippingProfileService
Provides layer to manipulate profiles.
Implements
Hierarchy
TransactionBaseService
↳
ShippingProfileService
Constructors
constructor
new ShippingProfileService(«destructured»
)
Parameters
Name |
---|
«destructured» |
Overrides
TransactionBaseService.constructor
Defined in
medusa/src/services/shipping-profile.ts:49
Properties
__configModule__
Protected
Optional
Readonly
__configModule__: Record<string
, unknown
>
Inherited from
TransactionBaseService.__configModule__
Defined in
medusa/src/interfaces/transaction-base-service.ts:14
__container__
Protected
Readonly
__container__: any
Inherited from
TransactionBaseService.__container__
Defined in
medusa/src/interfaces/transaction-base-service.ts:13
__moduleDeclaration__
Protected
Optional
Readonly
__moduleDeclaration__: Record<string
, unknown
>
Inherited from
TransactionBaseService.__moduleDeclaration__
Defined in
medusa/src/interfaces/transaction-base-service.ts:15
customShippingOptionService_
Protected
Readonly
customShippingOptionService_: CustomShippingOptionService
Defined in
medusa/src/services/shipping-profile.ts:43
featureFlagRouter_
Protected
Readonly
featureFlagRouter_: FlagRouter
Defined in
medusa/src/services/shipping-profile.ts:47
manager_
Protected
manager_: EntityManager
Inherited from
TransactionBaseService.manager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:5
productRepository_
Protected
Readonly
productRepository_: Repository
<Product
> & { _applyCategoriesQuery
: Method _applyCategoriesQuery ; _findWithRelations
: Method _findWithRelations ; bulkAddToCollection
: Method bulkAddToCollection ; bulkRemoveFromCollection
: Method bulkRemoveFromCollection ; findOneWithRelations
: Method findOneWithRelations ; findWithRelations
: Method findWithRelations ; findWithRelationsAndCount
: Method findWithRelationsAndCount ; getCategoryIdsFromInput
: Method getCategoryIdsFromInput ; getCategoryIdsRecursively
: Method getCategoryIdsRecursively ; getFreeTextSearchResultsAndCount
: Method getFreeTextSearchResultsAndCount ; isProductInSalesChannels
: Method isProductInSalesChannels ; queryProducts
: Method queryProducts ; queryProductsWithIds
: Method queryProductsWithIds }
Defined in
medusa/src/services/shipping-profile.ts:46
productService_
Protected
Readonly
productService_: ProductService
Defined in
medusa/src/services/shipping-profile.ts:41
shippingOptionService_
Protected
Readonly
shippingOptionService_: ShippingOptionService
Defined in
medusa/src/services/shipping-profile.ts:42
shippingProfileRepository_
Protected
Readonly
shippingProfileRepository_: Repository
<ShippingProfile
> & { findByProducts
: Method findByProducts }
Defined in
medusa/src/services/shipping-profile.ts:45
transactionManager_
Protected
transactionManager_: undefined
| EntityManager
Inherited from
TransactionBaseService.transactionManager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:6
Accessors
activeManager_
Protected
get
activeManager_(): EntityManager
Returns
EntityManager
-EntityManager
:
Inherited from
TransactionBaseService.activeManager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:8
Methods
addProduct
addProduct(profileId
, productId
): Promise
<ShippingProfile
>
Parameters
Name |
---|
profileId |
productId |
Returns
Promise
<ShippingProfile
>
-Promise
:
-ShippingProfile
:
Deprecated
use addProducts instead
Defined in
medusa/src/services/shipping-profile.ts:371
addProducts
addProducts(profileId
, productId
): Promise
<ShippingProfile
>
Adds a product or an array of products to the profile.
Parameters
Name | Description |
---|---|
profileId | string |
productId | string | string [] |
Returns
Promise
<ShippingProfile
>
-Promise
: the result of update
-ShippingProfile
:
Defined in
medusa/src/services/shipping-profile.ts:384
addShippingOption
addShippingOption(profileId
, optionId
): Promise
<ShippingProfile
>
Adds a shipping option to the profile. The shipping option can be used to fulfill the products in the products field.
Parameters
Name | Description |
---|---|
profileId | string |
optionId | string | string [] |
Returns
Promise
<ShippingProfile
>
-Promise
: the result of the model update operation
-ShippingProfile
:
Defined in
medusa/src/services/shipping-profile.ts:427
atomicPhase_
Protected
atomicPhase_<TResult
, TError
>(work
, isolationOrErrorHandler?
, maybeErrorHandlerOrDontFail?
): Promise
<TResult
>
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.
Name |
---|
TResult |
TError |
Parameters
Name | Description |
---|---|
work | (transactionManager : EntityManager ) => Promise <TResult > |
isolationOrErrorHandler? | IsolationLevel | (error : TError ) => Promise <void | TResult > |
maybeErrorHandlerOrDontFail? | (error : TError ) => Promise <void | TResult > |
Returns
Promise
<TResult
>
-Promise
: the result of the transactional work
Inherited from
TransactionBaseService.atomicPhase_
Defined in
medusa/src/interfaces/transaction-base-service.ts:56
create
create(profile
): Promise
<ShippingProfile
>
Creates a new shipping profile.
Parameters
Name | Description |
---|---|
profile | CreateShippingProfile |
Returns
Promise
<ShippingProfile
>
-Promise
: the result of the create operation
-ShippingProfile
:
Defined in
medusa/src/services/shipping-profile.ts:275
createDefault
createDefault(): Promise
<ShippingProfile
>
Creates a default shipping profile, if this does not already exist.
Returns
Promise
<ShippingProfile
>
-Promise
: the shipping profile
-ShippingProfile
:
Defined in
medusa/src/services/shipping-profile.ts:205
createGiftCardDefault
createGiftCardDefault(): Promise
<ShippingProfile
>
Creates a default shipping profile, for gift cards if unless it already exists.
Returns
Promise
<ShippingProfile
>
-Promise
: the shipping profile
-ShippingProfile
:
Defined in
medusa/src/services/shipping-profile.ts:249
delete
delete(profileId
): Promise
<void
>
Deletes a profile with a given profile id.
Parameters
Name | Description |
---|---|
profileId | string |
Returns
Promise
<void
>
-Promise
: the result of the delete operation.
Defined in
medusa/src/services/shipping-profile.ts:349
fetchCartOptions
fetchCartOptions(cart
): Promise
<ShippingOption
[]>
Finds all the shipping profiles that cover the products in a cart, and validates all options that are available for the cart.
Parameters
Name | Description |
---|---|
cart | any |
Returns
Promise
<ShippingOption
[]>
-Promise
: a list of the available shipping options
-ShippingOption[]
:
-ShippingOption
:
Defined in
medusa/src/services/shipping-profile.ts:452
getMapProfileIdsByProductIds
getMapProfileIdsByProductIds(productIds
): Promise
<Map
<string
, string
>>
Parameters
Name |
---|
productIds |
Returns
Promise
<Map
<string
, string
>>
-Promise
:
-Map
:
-string
: (optional)
-string
: (optional)
Defined in
medusa/src/services/shipping-profile.ts:88
getProfilesInCart
Protected
getProfilesInCart(cart
): Promise
<string
[]>
Returns a list of all the productIds in the cart.
Parameters
Name | Description |
---|---|
cart | Cart |
Returns
Promise
<string
[]>
-Promise
: a list of product ids
-string[]
:
-string
: (optional)
Defined in
medusa/src/services/shipping-profile.ts:518
list
list(selector?
, config?
): Promise
<ShippingProfile
[]>
Parameters
Name | Description |
---|---|
selector | Selector <ShippingProfile > |
config | FindConfig <ShippingProfile > |
Returns
Promise
<ShippingProfile
[]>
-Promise
: the result of the find operation
-ShippingProfile[]
:
-ShippingProfile
:
Defined in
medusa/src/services/shipping-profile.ts:73
removeProducts
removeProducts(profileId
, productId
): Promise
<void
| ShippingProfile
>
Removes a product or an array of products from the profile.
Parameters
Name | Description |
---|---|
profileId | null | string |
productId | string | string [] |
Returns
Promise
<void
| ShippingProfile
>
-Promise
: the result of update
-void \| ShippingProfile
: (optional)
Defined in
medusa/src/services/shipping-profile.ts:406
retrieve
retrieve(profileId
, options?
): Promise
<ShippingProfile
>
Gets a profile by id. Throws in case of DB Error and if profile was not found.
Parameters
Name | Description |
---|---|
profileId | string |
options | FindConfig <ShippingProfile > |
Returns
Promise
<ShippingProfile
>
-Promise
: the profile document.
-ShippingProfile
:
Defined in
medusa/src/services/shipping-profile.ts:130
retrieveDefault
retrieveDefault(): Promise
<null
| ShippingProfile
>
Returns
Promise
<null
| ShippingProfile
>
-Promise
:
-`null
| ShippingProfile`: (optional)
Defined in
medusa/src/services/shipping-profile.ts:189
retrieveForProducts
retrieveForProducts(productIds
): Promise
<{ [product_id: string]
: ShippingProfile
[]; }>
Parameters
Name |
---|
productIds |
Returns
Promise
<{ [product_id: string]
: ShippingProfile
[]; }>
-Promise
:
-object
: (optional)
Defined in
medusa/src/services/shipping-profile.ts:159
retrieveGiftCardDefault
retrieveGiftCardDefault(): Promise
<null
| ShippingProfile
>
Retrieves the default gift card profile
Returns
Promise
<null
| ShippingProfile
>
-Promise
: the shipping profile for gift cards
-`null
| ShippingProfile`: (optional)
Defined in
medusa/src/services/shipping-profile.ts:232
shouldRetryTransaction_
Protected
shouldRetryTransaction_(err
): boolean
Parameters
Name |
---|
err |
Returns
boolean
-boolean
: (optional)
Inherited from
TransactionBaseService.shouldRetryTransaction_
Defined in
medusa/src/interfaces/transaction-base-service.ts:37
update
update(profileId
, update
): Promise
<ShippingProfile
>
Updates a profile. Metadata updates and product updates should use
dedicated methods, e.g. setMetadata
, addProduct
, etc. The function
will throw errors if metadata or product updates are attempted.
Parameters
Name | Description |
---|---|
profileId | string |
update | UpdateShippingProfile |
Returns
Promise
<ShippingProfile
>
-Promise
: resolves to the update result.
-ShippingProfile
:
Defined in
medusa/src/services/shipping-profile.ts:310
withTransaction
withTransaction(transactionManager?
): ShippingProfileService
Parameters
Name |
---|
transactionManager? |
Returns
-ShippingProfileService
:
Inherited from
TransactionBaseService.withTransaction