ShippingCalculator

ShippingCalculator

The ShippingCalculator is used by a ShippingMethod to calculate the price of shipping on a given Order.

Example

const flatRateCalculator = new ShippingCalculator({
    code: 'flat-rate-calculator',
    description: 'Default Flat-Rate Shipping Calculator',
    args: {
        rate: ConfigArgType.MONEY,
    },
    calculate: (order, args) => {
        return args.rate;
    },
});

Signature

class ShippingCalculator<T extends ShippingCalculatorArgs = {}> implements ConfigurableOperationDef {
  constructor(config: { args: T; calculate: CalculateShippingFn<T>; code: string; description: string })
}

Members

constructor

method
type:
(config: { args: T; calculate: CalculateShippingFn<T>; code: string; description: string }) => ShippingCalculator