ShippingEligibilityChecker

ShippingEligibilityChecker

ShippingEligibilityChecker

The ShippingEligibilityChecker class is used to check whether an order qualifies for a given ShippingMethod.

Example

const minOrderTotalEligibilityChecker = new ShippingEligibilityChecker({
    code: 'min-order-total-eligibility-checker',
    description: [{ languageCode: LanguageCode.en, value: 'Checks that the order total is above some minimum value' }],
    args: {
        orderMinimum: { type: 'int', config: { inputType: 'money' } },
    },
    check: (order, args) => {
        return order.total >= args.orderMinimum;
    },
});

Signature

class ShippingEligibilityChecker<T extends ShippingEligibilityCheckerArgs = {}> implements ConfigurableOperationDef {
  constructor(config: {
        args: T;
        check: CheckShippingEligibilityCheckerFn<T>;
        code: string;
        description: LocalizedStringArray;
    })
}

Members

constructor

method
type:
(config: { args: T; check: CheckShippingEligibilityCheckerFn<T>; code: string; description: LocalizedStringArray; }) => ShippingEligibilityChecker

CheckShippingEligibilityCheckerFn

A function which implements logic to determine whether a given Order is eligible for a particular shipping method.

Signature

type CheckShippingEligibilityCheckerFn<T extends ShippingEligibilityCheckerArgs> = (
    order: Order,
    args: ConfigArgValues<T>,
) => boolean | Promise<boolean>