--- displayed_sidebar: servicesSidebar --- import ParameterTypes from "@site/src/components/ParameterTypes" # ShippingOptionService Provides layer to manipulate profiles. ## constructor ### 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": "featureFlagRouter_", "type": "`FlagRouter`", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "manager_", "type": "`EntityManager`", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "methodRepository_", "type": "Repository<[ShippingMethod](../../entities/classes/entities.ShippingMethod.mdx)>", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "optionRepository_", "type": "Repository<[ShippingOption](../../entities/classes/entities.ShippingOption.mdx)> & `object`", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "providerService_", "type": "[FulfillmentProviderService](services.FulfillmentProviderService.mdx)", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "regionService_", "type": "[RegionService](services.RegionService.mdx)", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "requirementRepository_", "type": "Repository<[ShippingOptionRequirement](../../entities/classes/entities.ShippingOptionRequirement.mdx)>", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "transactionManager_", "type": "`undefined` \\| `EntityManager`", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ]} /> ___ ## Accessors ### activeManager\_ #### Returns ___ ## Methods ### addRequirement Adds a requirement to a shipping option. Only 1 requirement of each type is allowed. #### Parameters #### Returns ___ ### 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. #### Type Parameters #### 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 ___ ### create Creates a new shipping option. Used both for outbound and inbound shipping options. The difference is registered by the `is_return` field which defaults to false. #### Parameters #### Returns ___ ### createShippingMethod Creates a shipping method for a given cart. #### Parameters `", "description": "the optional provider data to use.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "config", "type": "`CreateShippingMethodDto`", "description": "the cart to create the shipping method for.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ]} /> #### Returns ___ ### delete Deletes a profile with a given profile id. #### Parameters #### Returns ___ ### deleteShippingMethods Removes a given shipping method #### Parameters #### Returns ___ ### getPrice\_ Returns the amount to be paid for a shipping method. Will ask the fulfillment provider to calculate the price if the shipping option has the price type "calculated". #### Parameters `", "description": "the shipping data to retrieve the price.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "cart", "type": "`undefined` \\| [Order](../../entities/classes/entities.Order.mdx) \\| [Cart](../../entities/classes/entities.Cart.mdx)", "description": "the context in which the price should be\n retrieved.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ]} /> #### Returns ___ ### list #### Parameters #### Returns ___ ### listAndCount #### Parameters #### Returns ___ ### removeRequirement Removes a requirement from a shipping option #### Parameters #### Returns ___ ### retrieve Gets a profile by id. Throws in case of DB Error and if profile was not found. #### Parameters #### Returns ___ ### shouldRetryTransaction\_ #### Parameters ` \\| `object`", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ]} /> #### Returns ___ ### update Updates a profile. Metadata updates and product updates should use dedicated methods, e.g. `setMetadata`, etc. The function will throw errors if metadata or product updates are attempted. #### Parameters #### Returns ___ ### updateShippingMethod Updates a shipping method's associations. Useful when a cart is completed and its methods should be copied to an order/swap entity. #### Parameters #### Returns ___ ### updateShippingProfile #### Parameters #### Returns ___ ### validateAndMutatePrice #### Parameters #### Returns ___ ### validateCartOption Checks if a given option id is a valid option for a cart. If it is the option is returned with the correct price. Throws when region\_ids do not match, or when the shipping option requirements are not satisfied. #### Parameters #### Returns ___ ### validatePriceType\_ Validates a shipping option price #### Parameters #### Returns ___ ### validateRequirement\_ Validates a requirement #### Parameters #### Returns ___ ### withTransaction #### Parameters #### Returns