ShippingOptionService
Provides layer to manipulate profiles.
constructor
Parameters
__namedParameters
InjectedDependenciesRequiredProperties
manager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequired__container__
anyRequiredfeatureFlagRouter_
FlagRouterRequired__configModule__
Record<string, unknown>__moduleDeclaration__
Record<string, unknown>Accessors
activeManager_
Returns
EntityManager
EntityManagerRequiredMethods
withTransaction
Parameters
transactionManager
EntityManagerReturns
this
thisRequiredshouldRetryTransaction_
Parameters
err
Record<string, unknown> | objectRequiredReturns
boolean
booleanRequiredatomicPhase_
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>RequiredvalidateRequirement_
Validates a requirement
Parameters
requirement
ValidateRequirementTypeInputRequiredoptionId
undefined | 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
optionId
anyRequiredDefault: {}
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
id
stringRequiredupdate
ShippingMethodUpdateRequiredReturns
deleteShippingMethods
Removes a given shipping method
Parameters
Returns
createShippingMethod
Creates a shipping method for a given cart.
Parameters
optionId
stringRequireddata
Record<string, unknown>Requiredconfig
CreateShippingMethodDtoRequiredReturns
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
priceInput
ValidatePriceTypeAndAmountInputRequiredReturns
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
data
CreateShippingOptionInputRequiredReturns
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
optionId
stringRequiredupdate
UpdateShippingOptionInputRequiredReturns
delete
Deletes a profile with a given profile id.
Parameters
optionId
stringRequiredReturns
addRequirement
Adds a requirement to a shipping option. Only 1 requirement of each type is allowed.
Parameters
optionId
stringRequiredReturns
removeRequirement
Removes a requirement from a shipping option
Parameters
requirementId
anyRequiredReturns
updateShippingProfile
Parameters
optionIds
string | string[]RequiredprofileId
stringRequiredReturns
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>Required