@hungr/types
    Preparing search index...

    Type Alias DiscountRule

    DiscountRule: {
        id: string;
        menuId: string | null;
        menuItemId: string | null;
        discountKind: "flat" | "percent";
        discountAmount: number;
        maxDiscountAmount: number | null;
        maxDiscountQuantity: number | null;
        conditions: {
            menuId: string | null;
            menuItemId: string | null;
            minQuantity: number | null;
            minPrice: number | null;
        }[];
    }

    One rule of a discount: which items it discounts, by how much, and when it applies. Rules only exist inside a discount.

    Type Declaration

    • id: string

      ID of the rule, unique within its discount. Set by the server.

    • The menu whose items the rule discounts, or null for items from any of the vendor's menus.

    • The item the rule discounts, or null for every item of menuId. Must be null when menuId is null.

    • discountKind: "flat" | "percent"

      "flat" takes a fixed amount off each discounted item. "percent" takes a fraction of each discounted item's price.

    • discountAmount: number

      For "flat", the amount in NZD cents taken off each discounted item (1500 = $15.00). For "percent", the fraction of the price taken off, greater than 0 and at most 1 (0.5 = 50%).

    • maxDiscountAmount: number | null

      For "percent" only: cap in NZD cents on the total the rule takes off, or null for no cap. Always null for "flat".

    • maxDiscountQuantity: number | null

      Maximum number of item units the rule discounts, or null for no limit. When more units qualify, the ones giving the biggest discount are chosen.

    • conditions: {
          menuId: string | null;
          menuItemId: string | null;
          minQuantity: number | null;
          minPrice: number | null;
      }[]

      The rule applies only if the cart meets every condition. An empty list means it always applies.