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 = {}> extends ConfigurableOperationDef<T> {
  constructor(config: ShippingEligibilityCheckerConfig<T>)
}

Extends

Members

constructor

method
type:
(config: ShippingEligibilityCheckerConfig<T>) => 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>