ShippingOptionService
Provides layer to manipulate profiles.
constructor
Parameters
__namedParameters
InjectedDependenciesRequiredProperties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>featureFlagRouter_
FlagRouterRequiredmanager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequiredAccessors
activeManager_
Returns
EntityManager
EntityManagerRequiredMethods
addRequirement
Adds a requirement to a shipping option. Only 1 requirement of each type is allowed.
Parameters
optionId
stringRequiredReturns
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
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise
Promise<TResult>Requiredcreate
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
data
CreateShippingOptionInputRequiredReturns
createShippingMethod
Creates a shipping method for a given cart.
Parameters
optionId
stringRequireddata
Record<string, unknown>Requiredconfig
CreateShippingMethodDtoRequiredReturns
delete
Deletes a profile with a given profile id.
Parameters
optionId
stringRequiredReturns
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
data
Record<string, unknown>RequiredReturns
Promise
Promise<number>Requiredlist
Parameters
Returns
listAndCount
Parameters
Returns
removeRequirement
Removes a requirement from a shipping option
Parameters
requirementId
anyRequiredReturns
retrieve
Gets a profile by id. Throws in case of DB Error and if profile was not found.
Parameters
optionId
anyRequiredDefault: {}
Returns
shouldRetryTransaction_
Parameters
err
Record<string, unknown> | objectRequiredReturns
boolean
booleanupdate
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
optionId
stringRequiredupdate
UpdateShippingOptionInputRequiredReturns
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
id
stringRequiredupdate
ShippingMethodUpdateRequiredReturns
updateShippingProfile
Parameters
optionIds
string | string[]RequiredprofileId
stringRequiredReturns
validateAndMutatePrice
Parameters
priceInput
ValidatePriceTypeAndAmountInputRequiredReturns
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
optionId
undefined | stringRequiredDefault: undefined
Returns
withTransaction
Parameters
transactionManager
EntityManagerReturns
ShippingOptionService
objectRequired