--- displayed_sidebar: servicesSidebar --- import ParameterTypes from "@site/src/components/ParameterTypes" # ShippingProfileService Provides layer to manipulate profiles. #### Implements ## Constructors ### constructor `**new ShippingProfileService**(«destructured»)` #### Parameters ## Properties `", "description": "", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "__container__", "type": "`any`", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "__moduleDeclaration__", "type": "`Record`", "description": "", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "customShippingOptionService_", "type": "[CustomShippingOptionService](CustomShippingOptionService.mdx)", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "featureFlagRouter_", "type": "[FlagRouter](FlagRouter.mdx)", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "manager_", "type": "EntityManager", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "productRepository_", "type": "Repository<[Product](Product.mdx)> & `{ _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 }`", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "productService_", "type": "[ProductService](ProductService.mdx)", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "shippingOptionService_", "type": "[ShippingOptionService](ShippingOptionService.mdx)", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "shippingProfileRepository_", "type": "Repository<[ShippingProfile](ShippingProfile.mdx)> & `{ findByProducts: Method findByProducts }`", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "transactionManager_", "type": "`undefined` \\| EntityManager", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ]} /> ## Accessors ### activeManager\_ `Protected get**activeManager_**(): EntityManager` #### Returns EntityManager ## Methods ### addProduct `**addProduct**(profileId, productId): Promise<[ShippingProfile](ShippingProfile.mdx)>` #### Parameters #### Returns Promise<[ShippingProfile](ShippingProfile.mdx)> #### Deprecated use [addProducts](ShippingProfileService.mdx#addproducts) instead ___ ### addProducts `**addProducts**(profileId, productId): Promise<[ShippingProfile](ShippingProfile.mdx)>` Adds a product or an array of products to the profile. #### Parameters #### Returns Promise<[ShippingProfile](ShippingProfile.mdx)> ___ ### addShippingOption `**addShippingOption**(profileId, optionId): Promise<[ShippingProfile](ShippingProfile.mdx)>` Adds a shipping option to the profile. The shipping option can be used to fulfill the products in the products field. #### Parameters #### Returns Promise<[ShippingProfile](ShippingProfile.mdx)> ___ ### atomicPhase\_ `Protected **atomicPhase_**(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. #### Parameters Promise<TResult>", "description": "the transactional work to be done", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "isolationOrErrorHandler", "type": "`IsolationLevel` \\| (`error`: `TError`) => Promise<void \\| TResult>", "description": "the isolation level to be used for the work.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "maybeErrorHandlerOrDontFail", "type": "(`error`: `TError`) => Promise<void \\| TResult>", "description": "Potential error handler", "optional": true, "defaultValue": "", "expandable": false, "children": [] } ]} /> #### Returns Promise<TResult> ___ ### create `**create**(profile): Promise<[ShippingProfile](ShippingProfile.mdx)>` Creates a new shipping profile. #### Parameters #### Returns Promise<[ShippingProfile](ShippingProfile.mdx)> ___ ### createDefault `**createDefault**(): Promise<[ShippingProfile](ShippingProfile.mdx)>` Creates a default shipping profile, if this does not already exist. #### Returns Promise<[ShippingProfile](ShippingProfile.mdx)> ___ ### createGiftCardDefault `**createGiftCardDefault**(): Promise<[ShippingProfile](ShippingProfile.mdx)>` Creates a default shipping profile, for gift cards if unless it already exists. #### Returns Promise<[ShippingProfile](ShippingProfile.mdx)> ___ ### delete `**delete**(profileId): Promise<void>` Deletes a profile with a given profile id. #### Parameters #### Returns Promise<void> ___ ### fetchCartOptions `**fetchCartOptions**(cart): Promise<[ShippingOption](ShippingOption.mdx)[]>` Finds all the shipping profiles that cover the products in a cart, and validates all options that are available for the cart. #### Parameters #### Returns Promise<[ShippingOption](ShippingOption.mdx)[]> ___ ### getMapProfileIdsByProductIds `**getMapProfileIdsByProductIds**(productIds): Promise<Map<string, string>>` #### Parameters #### Returns Promise<Map<string, string>> ___ ### getProfilesInCart `Protected **getProfilesInCart**(cart): Promise<string[]>` Returns a list of all the productIds in the cart. #### Parameters #### Returns Promise<string[]> ___ ### list `**list**(selector?, config?): Promise<[ShippingProfile](ShippingProfile.mdx)[]>` #### Parameters #### Returns Promise<[ShippingProfile](ShippingProfile.mdx)[]> ___ ### removeProducts `**removeProducts**(profileId, productId): Promise<void \| [ShippingProfile](ShippingProfile.mdx)>` Removes a product or an array of products from the profile. #### Parameters #### Returns Promise<void \| [ShippingProfile](ShippingProfile.mdx)> ___ ### retrieve `**retrieve**(profileId, options?): Promise<[ShippingProfile](ShippingProfile.mdx)>` Gets a profile by id. Throws in case of DB Error and if profile was not found. #### Parameters #### Returns Promise<[ShippingProfile](ShippingProfile.mdx)> ___ ### retrieveDefault `**retrieveDefault**(): Promise<`null` \| [ShippingProfile](ShippingProfile.mdx)>` #### Returns Promise<`null` \| [ShippingProfile](ShippingProfile.mdx)> ___ ### retrieveForProducts `**retrieveForProducts**(productIds): Promise<{ [product_id: string]: [ShippingProfile](ShippingProfile.mdx)[]; }>` #### Parameters #### Returns Promise<{ [product_id: string]: [ShippingProfile](ShippingProfile.mdx)[]; }> ___ ### retrieveGiftCardDefault `**retrieveGiftCardDefault**(): Promise<`null` \| [ShippingProfile](ShippingProfile.mdx)>` Retrieves the default gift card profile #### Returns Promise<`null` \| [ShippingProfile](ShippingProfile.mdx)> ___ ### shouldRetryTransaction\_ `Protected **shouldRetryTransaction_**(err): boolean` #### Parameters ` \\| `{ code: string }`", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ]} /> #### Returns `boolean` ___ ### update `**update**(profileId, update): Promise<[ShippingProfile](ShippingProfile.mdx)>` 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 #### Returns Promise<[ShippingProfile](ShippingProfile.mdx)> ___ ### withTransaction `**withTransaction**(transactionManager?): [ShippingProfileService](ShippingProfileService.mdx)` #### Parameters #### Returns [ShippingProfileService](ShippingProfileService.mdx)