ShippingCalculator

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: { type: 'int', config: { inputType: '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: LocalizedStringArray;
    })
}

Members

constructor

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