Skip to main content
Skip to main content

ShippingProfileService

Provides layer to manipulate profiles.

Implements

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
customShippingOptionService_CustomShippingOptionServiceRequired
featureFlagRouter_FlagRouterRequired
manager_EntityManagerRequired
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 }Required
productService_ProductServiceRequired
shippingOptionService_ShippingOptionServiceRequired
shippingProfileRepository_Repository<ShippingProfile> & { findByProducts: Method findByProducts }Required
transactionManager_undefined | EntityManagerRequired

Accessors

activeManager_

Inherited from

TransactionBaseService.activeManager_

Methods

addProduct

Parameters
profileIdstringRequired
productIdstring | string[]Required
Returns
PromisePromise<ShippingProfile>Required

Deprecated

use addProducts instead


addProducts

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

Parameters
profileIdstringRequired
the profile to add the products to.
productIdstring | string[]Required
the ID of the product or multiple products to add.
Returns
PromisePromise<ShippingProfile>Required
the result of update

addShippingOption

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

Parameters
profileIdstringRequired
the profile to apply the shipping option to
optionIdstring | string[]Required
the ID of the option or multiple options to add to the profile
Returns
PromisePromise<ShippingProfile>Required
the result of the model update operation

atomicPhase_

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.

Parameters
work(transactionManager: EntityManager) => Promise<TResult>Required
the transactional work to be done
isolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>
the isolation level to be used for the work.
maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>
Potential error handler
Returns
PromisePromise<TResult>Required
the result of the transactional work

create

Creates a new shipping profile.

Parameters
profileCreateShippingProfileRequired
the shipping profile to create from
Returns
PromisePromise<ShippingProfile>Required
the result of the create operation

createDefault

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

Returns
PromisePromise<ShippingProfile>Required
the shipping profile

createGiftCardDefault

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

Returns
PromisePromise<ShippingProfile>Required
the shipping profile

delete

Deletes a profile with a given profile id.

Parameters
profileIdstringRequired
the id of the profile to delete. Must be castable as an ObjectId
Returns
PromisePromise<void>Required
the result of the delete operation.

fetchCartOptions

Finds all the shipping profiles that cover the products in a cart, and validates all options that are available for the cart.

Parameters
cartanyRequired
the cart object to find shipping options for
Returns
PromisePromise<ShippingOption[]>Required
a list of the available shipping options

getMapProfileIdsByProductIds

Parameters
productIdsstring[]Required
Returns
PromisePromise<Map<string, string>>Required

getProfilesInCart

Returns a list of all the productIds in the cart.

Parameters
cartCartRequired
the cart to extract products from
Returns
PromisePromise<string[]>Required
a list of product ids

list

Parameters
the query object for find
the config object for find
Returns
PromisePromise<ShippingProfile[]>Required
the result of the find operation

removeProducts

Removes a product or an array of products from the profile.

Parameters
profileIdnull | stringRequired
the profile to add the products to.
productIdstring | string[]Required
the ID of the product or multiple products to add.
Returns
PromisePromise<void | ShippingProfile>Required
the result of update

retrieve

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

Parameters
profileIdstringRequired
the id of the profile to get.
options opf the query.
Returns
PromisePromise<ShippingProfile>Required
the profile document.

retrieveDefault

Returns
PromisePromise<null | ShippingProfile>Required

retrieveForProducts

Parameters
productIdsstring | string[]Required
Returns
PromisePromise<{ [product_id: string]: ShippingProfile[]; }>Required

retrieveGiftCardDefault

Retrieves the default gift card profile

Returns
PromisePromise<null | ShippingProfile>Required
the shipping profile for gift cards

shouldRetryTransaction_

Parameters
errRecord<string, unknown> | { code: string }Required
Returns
booleanboolean

update

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
profileIdstringRequired
the id of the profile. Must be a string that can be casted to an ObjectId
updateUpdateShippingProfileRequired
an object with the update values.
Returns
PromisePromise<ShippingProfile>Required
resolves to the update result.

withTransaction

Parameters
transactionManagerEntityManager
Returns
ShippingProfileServiceShippingProfileServiceRequired
Was this section helpful?