ShippingOptionService
Provides layer to manipulate profiles.
constructor
Parameters
__namedParametersInjectedDependenciesRequiredProperties
manager_EntityManagerRequiredtransactionManager_undefined | EntityManagerRequired__container__anyRequiredfeatureFlagRouter_FlagRouterRequired__configModule__Record<string, unknown>__moduleDeclaration__Record<string, unknown>Accessors
activeManager_
Returns
EntityManagerEntityManagerRequiredMethods
withTransaction
Parameters
transactionManagerEntityManagerReturns
thisthisRequiredshouldRetryTransaction_
Parameters
errRecord<string, unknown> | objectRequiredReturns
booleanbooleanRequiredatomicPhase_
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
TResultobjectRequiredTErrorobjectRequiredParameters
work(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>Returns
PromisePromise<TResult>RequiredvalidateRequirement_
Validates a requirement
Parameters
requirementValidateRequirementTypeInputRequiredoptionIdundefined | stringRequiredDefault: undefined
Returns
list
Parameters
Default: {}
Returns
listAndCount
Parameters
Default: {}
Returns
retrieve
Gets a profile by id. Throws in case of DB Error and if profile was not found.
Parameters
optionIdanyRequiredDefault: {}
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
idstringRequiredupdateShippingMethodUpdateRequiredReturns
deleteShippingMethods
Removes a given shipping method
Parameters
Returns
createShippingMethod
Creates a shipping method for a given cart.
Parameters
optionIdstringRequireddataRecord<string, unknown>RequiredconfigCreateShippingMethodDtoRequiredReturns
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
validateAndMutatePrice
Parameters
priceInputValidatePriceTypeAndAmountInputRequiredReturns
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
dataCreateShippingOptionInputRequiredReturns
validatePriceType_
Validates a shipping option price
Parameters
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
optionIdstringRequiredupdateUpdateShippingOptionInputRequiredReturns
delete
Deletes a profile with a given profile id.
Parameters
optionIdstringRequiredReturns
addRequirement
Adds a requirement to a shipping option. Only 1 requirement of each type is allowed.
Parameters
optionIdstringRequiredReturns
removeRequirement
Removes a requirement from a shipping option
Parameters
requirementIdanyRequiredReturns
updateShippingProfile
Parameters
optionIdsstring | string[]RequiredprofileIdstringRequiredReturns
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
dataRecord<string, unknown>RequiredReturns
PromisePromise<number>Required