Skip to main content

Class: ShippingProfileService

Provides layer to manipulate profiles.

ImplementsCopy to Clipboard

Hierarchy

  • TransactionBaseServiceCopy to Clipboard

    ShippingProfileServiceCopy to Clipboard

Constructors

constructor

new ShippingProfileService(__namedParametersCopy to Clipboard)

Parameters

NameType
__namedParametersCopy to ClipboardInjectedDependenciesCopy to Clipboard

Overrides

TransactionBaseService.constructor

Defined in

medusa/src/services/shipping-profile.ts:45

Properties

__configModule__

ProtectedCopy to Clipboard OptionalCopy to Clipboard ReadonlyCopy to Clipboard __configModule__: RecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard>

Inherited from

TransactionBaseService.__configModule__

Defined in

medusa/src/interfaces/transaction-base-service.ts:14


__container__

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard __container__: anyCopy to Clipboard

Inherited from

TransactionBaseService.__container__

Defined in

medusa/src/interfaces/transaction-base-service.ts:13


__moduleDeclaration__

ProtectedCopy to Clipboard OptionalCopy to Clipboard ReadonlyCopy to Clipboard __moduleDeclaration__: RecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard>

Inherited from

TransactionBaseService.__moduleDeclaration__

Defined in

medusa/src/interfaces/transaction-base-service.ts:15


customShippingOptionService_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard customShippingOptionService_: CustomShippingOptionServiceCopy to Clipboard

Defined in

medusa/src/services/shipping-profile.ts:40


manager_

ProtectedCopy to Clipboard manager_: EntityManagerCopy to Clipboard

Inherited from

TransactionBaseService.manager_

Defined in

medusa/src/interfaces/transaction-base-service.ts:5


productRepository_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard productRepository_: RepositoryCopy to Clipboard<ProductCopy to Clipboard> & { _applyCategoriesQueryCopy to Clipboard: (qbCopy to Clipboard: SelectQueryBuilderCopy to Clipboard<ProductCopy to Clipboard>, __namedParametersCopy to Clipboard: ObjectCopy to Clipboard) => SelectQueryBuilderCopy to Clipboard<ProductCopy to Clipboard> ; _findWithRelationsCopy to Clipboard: (__namedParametersCopy to Clipboard: { idsOrOptionsWithoutRelationsCopy to Clipboard: stringCopy to Clipboard[] | FindWithoutRelationsOptionsCopy to Clipboard ; relationsCopy to Clipboard: stringCopy to Clipboard[] ; shouldCountCopy to Clipboard: booleanCopy to Clipboard ; withDeletedCopy to Clipboard: booleanCopy to Clipboard }) => PromiseCopy to Clipboard<[ProductCopy to Clipboard[], numberCopy to Clipboard]> ; bulkAddToCollectionCopy to Clipboard: (productIdsCopy to Clipboard: stringCopy to Clipboard[], collectionIdCopy to Clipboard: stringCopy to Clipboard) => PromiseCopy to Clipboard<ProductCopy to Clipboard[]> ; bulkRemoveFromCollectionCopy to Clipboard: (productIdsCopy to Clipboard: stringCopy to Clipboard[], collectionIdCopy to Clipboard: stringCopy to Clipboard) => PromiseCopy to Clipboard<ProductCopy to Clipboard[]> ; findOneWithRelationsCopy to Clipboard: (relationsCopy to Clipboard: stringCopy to Clipboard[], optionsWithoutRelationsCopy to Clipboard: FindWithoutRelationsOptionsCopy to Clipboard) => PromiseCopy to Clipboard<ProductCopy to Clipboard> ; findWithRelationsCopy to Clipboard: (relationsCopy to Clipboard: stringCopy to Clipboard[], idsOrOptionsWithoutRelationsCopy to Clipboard: stringCopy to Clipboard[] | FindWithoutRelationsOptionsCopy to Clipboard, withDeletedCopy to Clipboard: booleanCopy to Clipboard) => PromiseCopy to Clipboard<ProductCopy to Clipboard[]> ; findWithRelationsAndCountCopy to Clipboard: (relationsCopy to Clipboard: stringCopy to Clipboard[], idsOrOptionsWithoutRelationsCopy to Clipboard: FindWithoutRelationsOptionsCopy to Clipboard) => PromiseCopy to Clipboard<[ProductCopy to Clipboard[], numberCopy to Clipboard]> ; getFreeTextSearchResultsAndCountCopy to Clipboard: (qCopy to Clipboard: stringCopy to Clipboard, optionsCopy to Clipboard: FindWithoutRelationsOptionsCopy to Clipboard, relationsCopy to Clipboard: stringCopy to Clipboard[]) => PromiseCopy to Clipboard<[ProductCopy to Clipboard[], numberCopy to Clipboard]> ; isProductInSalesChannelsCopy to Clipboard: (idCopy to Clipboard: stringCopy to Clipboard, salesChannelIdsCopy to Clipboard: stringCopy to Clipboard[]) => PromiseCopy to Clipboard<booleanCopy to Clipboard> ; queryProductsCopy to Clipboard: (optionsWithoutRelationsCopy to Clipboard: FindWithoutRelationsOptionsCopy to Clipboard, shouldCountCopy to Clipboard: booleanCopy to Clipboard) => PromiseCopy to Clipboard<[ProductCopy to Clipboard[], numberCopy to Clipboard]> ; queryProductsWithIdsCopy to Clipboard: (__namedParametersCopy to Clipboard: { entityIdsCopy to Clipboard: stringCopy to Clipboard[] ; groupedRelationsCopy to Clipboard: { [toplevel: string]Copy to Clipboard: stringCopy to Clipboard[]; } ; order?Copy to Clipboard: { [column: string]Copy to Clipboard: "ASC"Copy to Clipboard | "DESC"Copy to Clipboard; } ; select?Copy to Clipboard: keyof ProductCopy to Clipboard[] ; where?Copy to Clipboard: FindOptionsWhereCopy to Clipboard<ProductCopy to Clipboard> ; withDeleted?Copy to Clipboard: booleanCopy to Clipboard }) => PromiseCopy to Clipboard<ProductCopy to Clipboard[]> ; upsertShippingProfileCopy to Clipboard: (productIdsCopy to Clipboard: stringCopy to Clipboard[], shippingProfileIdCopy to Clipboard: stringCopy to Clipboard) => PromiseCopy to Clipboard<ProductCopy to Clipboard[]> }

Defined in

medusa/src/services/shipping-profile.ts:43


productService_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard productService_: ProductServiceCopy to Clipboard

Defined in

medusa/src/services/shipping-profile.ts:38


shippingOptionService_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard shippingOptionService_: ShippingOptionServiceCopy to Clipboard

Defined in

medusa/src/services/shipping-profile.ts:39


shippingProfileRepository_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard shippingProfileRepository_: RepositoryCopy to Clipboard<ShippingProfileCopy to Clipboard>

Defined in

medusa/src/services/shipping-profile.ts:42


transactionManager_

ProtectedCopy to Clipboard transactionManager_: undefinedCopy to Clipboard | EntityManagerCopy to Clipboard

Inherited from

TransactionBaseService.transactionManager_

Defined in

medusa/src/interfaces/transaction-base-service.ts:6

Accessors

activeManager_

ProtectedCopy to Clipboard getCopy to Clipboard activeManager_(): EntityManagerCopy to Clipboard

Returns

EntityManagerCopy to Clipboard

Inherited from

TransactionBaseService.activeManager_

Defined in

medusa/src/interfaces/transaction-base-service.ts:8

Methods

addProduct

addProduct(profileIdCopy to Clipboard, productIdCopy to Clipboard): PromiseCopy to Clipboard<ShippingProfileCopy to Clipboard>

Adds a product of an array of products to the profile.

Parameters

NameTypeDescription
profileIdCopy to ClipboardstringCopy to Clipboardthe profile to add the products to.
productIdCopy to ClipboardstringCopy to Clipboard | stringCopy to Clipboard[]the ID of the product or multiple products to add.

Returns

PromiseCopy to Clipboard<ShippingProfileCopy to Clipboard>

the result of update

Defined in

medusa/src/services/shipping-profile.ts:355


addShippingOption

addShippingOption(profileIdCopy to Clipboard, optionIdCopy to Clipboard): PromiseCopy to Clipboard<ShippingProfileCopy to Clipboard>

Adds a shipping option to the profile. The shipping option can be used to fulfill the products in the products field.

Parameters

NameTypeDescription
profileIdCopy to ClipboardstringCopy to Clipboardthe profile to apply the shipping option to
optionIdCopy to ClipboardstringCopy to Clipboard | stringCopy to Clipboard[]the ID of the option or multiple options to add to the profile

Returns

PromiseCopy to Clipboard<ShippingProfileCopy to Clipboard>

the result of the model update operation

Defined in

medusa/src/services/shipping-profile.ts:385


atomicPhase_

ProtectedCopy to Clipboard atomicPhase_<TResultCopy to Clipboard, TErrorCopy to Clipboard>(workCopy to Clipboard, isolationOrErrorHandler?Copy to Clipboard, maybeErrorHandlerOrDontFail?Copy to Clipboard): PromiseCopy to Clipboard<TResultCopy 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
TResultCopy to Clipboard
TErrorCopy to Clipboard

Parameters

NameTypeDescription
workCopy to Clipboard(transactionManagerCopy to Clipboard: EntityManagerCopy to Clipboard) => PromiseCopy to Clipboard<TResultCopy to Clipboard>the transactional work to be done
isolationOrErrorHandler?Copy to ClipboardIsolationLevelCopy to Clipboard | (errorCopy to Clipboard: TErrorCopy to Clipboard) => PromiseCopy to Clipboard<voidCopy to Clipboard | TResultCopy to Clipboard>the isolation level to be used for the work.
maybeErrorHandlerOrDontFail?Copy to Clipboard(errorCopy to Clipboard: TErrorCopy to Clipboard) => PromiseCopy to Clipboard<voidCopy to Clipboard | TResultCopy to Clipboard>Potential error handler

Returns

PromiseCopy to Clipboard<TResultCopy to Clipboard>

the result of the transactional work

Inherited from

TransactionBaseService.atomicPhase_

Defined in

medusa/src/interfaces/transaction-base-service.ts:56


create

create(profileCopy to Clipboard): PromiseCopy to Clipboard<ShippingProfileCopy to Clipboard>

Creates a new shipping profile.

Parameters

NameTypeDescription
profileCopy to ClipboardCreateShippingProfileCopy to Clipboardthe shipping profile to create from

Returns

PromiseCopy to Clipboard<ShippingProfileCopy to Clipboard>

the result of the create operation

Defined in

medusa/src/services/shipping-profile.ts:249


createDefault

createDefault(): PromiseCopy to Clipboard<ShippingProfileCopy to Clipboard>

Creates a default shipping profile, if this does not already exist.

Returns

PromiseCopy to Clipboard<ShippingProfileCopy to Clipboard>

the shipping profile

Defined in

medusa/src/services/shipping-profile.ts:179


createGiftCardDefault

createGiftCardDefault(): PromiseCopy to Clipboard<ShippingProfileCopy to Clipboard>

Creates a default shipping profile, for gift cards if unless it already exists.

Returns

PromiseCopy to Clipboard<ShippingProfileCopy to Clipboard>

the shipping profile

Defined in

medusa/src/services/shipping-profile.ts:223


delete

delete(profileIdCopy to Clipboard): PromiseCopy to Clipboard<voidCopy to Clipboard>

Deletes a profile with a given profile id.

Parameters

NameTypeDescription
profileIdCopy to ClipboardstringCopy to Clipboardthe id of the profile to delete. Must be castable as an ObjectId

Returns

PromiseCopy to Clipboard<voidCopy to Clipboard>

the result of the delete operation.

Defined in

medusa/src/services/shipping-profile.ts:330


fetchCartOptions

fetchCartOptions(cartCopy to Clipboard): PromiseCopy to Clipboard<ShippingOptionCopy 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

NameTypeDescription
cartCopy to ClipboardanyCopy to Clipboardthe cart object to find shipping options for

Returns

PromiseCopy to Clipboard<ShippingOptionCopy to Clipboard[]>

a list of the available shipping options

Defined in

medusa/src/services/shipping-profile.ts:415


fetchOptionsByProductIds

fetchOptionsByProductIds(productIdsCopy to Clipboard, filterCopy to Clipboard): PromiseCopy to Clipboard<ShippingOptionCopy to Clipboard[]>

Parameters

NameType
productIdsCopy to ClipboardstringCopy to Clipboard[]
filterCopy to ClipboardSelectorCopy to Clipboard<ShippingOptionCopy to Clipboard>

Returns

PromiseCopy to Clipboard<ShippingOptionCopy to Clipboard[]>

Defined in

medusa/src/services/shipping-profile.ts:82


getProfilesInCart

ProtectedCopy to Clipboard getProfilesInCart(cartCopy to Clipboard): stringCopy to Clipboard[]

Returns a list of all the productIds in the cart.

Parameters

NameTypeDescription
cartCopy to ClipboardCartCopy to Clipboardthe cart to extract products from

Returns

stringCopy 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): PromiseCopy to Clipboard<ShippingProfileCopy to Clipboard[]>

Parameters

NameTypeDescription
selectorCopy to ClipboardSelectorCopy to Clipboard<ShippingProfileCopy to Clipboard>the query object for find
configCopy to ClipboardFindConfigCopy to Clipboard<ShippingProfileCopy to Clipboard>the config object for find

Returns

PromiseCopy to Clipboard<ShippingProfileCopy to Clipboard[]>

the result of the find operation

Defined in

medusa/src/services/shipping-profile.ts:67


retrieve

retrieve(profileIdCopy to Clipboard, options?Copy to Clipboard): PromiseCopy to Clipboard<ShippingProfileCopy to Clipboard>

Gets a profile by id. Throws in case of DB Error and if profile was not found.

Parameters

NameTypeDescription
profileIdCopy to ClipboardstringCopy to Clipboardthe id of the profile to get.
optionsCopy to ClipboardFindConfigCopy to Clipboard<ShippingProfileCopy to Clipboard>options opf the query.

Returns

PromiseCopy to Clipboard<ShippingProfileCopy to Clipboard>

the profile document.

Defined in

medusa/src/services/shipping-profile.ts:134


retrieveDefault

retrieveDefault(): PromiseCopy to Clipboard<nullCopy to Clipboard | ShippingProfileCopy to Clipboard>

Returns

PromiseCopy to Clipboard<nullCopy to Clipboard | ShippingProfileCopy to Clipboard>

Defined in

medusa/src/services/shipping-profile.ts:163


retrieveGiftCardDefault

retrieveGiftCardDefault(): PromiseCopy to Clipboard<nullCopy to Clipboard | ShippingProfileCopy to Clipboard>

Retrieves the default gift card profile

Returns

PromiseCopy to Clipboard<nullCopy to Clipboard | ShippingProfileCopy to Clipboard>

the shipping profile for gift cards

Defined in

medusa/src/services/shipping-profile.ts:206


shouldRetryTransaction_

ProtectedCopy to Clipboard shouldRetryTransaction_(errCopy to Clipboard): booleanCopy to Clipboard

Parameters

NameType
errCopy to ClipboardRecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard> | { codeCopy to Clipboard: stringCopy to Clipboard }

Returns

booleanCopy to Clipboard

Inherited from

TransactionBaseService.shouldRetryTransaction_

Defined in

medusa/src/interfaces/transaction-base-service.ts:37


update

update(profileIdCopy to Clipboard, updateCopy to Clipboard): PromiseCopy to Clipboard<ShippingProfileCopy to Clipboard>

Updates a profile. Metadata updates and product updates should use dedicated methods, e.g. setMetadataCopy to Clipboard, addProductCopy to Clipboard, etc. The function will throw errors if metadata or product updates are attempted.

Parameters

NameTypeDescription
profileIdCopy to ClipboardstringCopy to Clipboardthe id of the profile. Must be a string that can be casted to an ObjectId
updateCopy to ClipboardUpdateShippingProfileCopy to Clipboardan object with the update values.

Returns

PromiseCopy to Clipboard<ShippingProfileCopy to Clipboard>

resolves to the update result.

Defined in

medusa/src/services/shipping-profile.ts:284


withTransaction

withTransaction(transactionManager?Copy to Clipboard): ShippingProfileServiceCopy to Clipboard

Parameters

NameType
transactionManager?Copy to ClipboardEntityManagerCopy to Clipboard

Returns

ShippingProfileServiceCopy to Clipboard

Inherited from

TransactionBaseService.withTransaction

Defined in

medusa/src/interfaces/transaction-base-service.ts:20

Was this page helpful?