Calculate order totals

This topic introduces how order totals are calculated and the basic concepts involved.

Basic concepts

Concept

Description

paymentAmount

Indicates the actual amount paid by users for an order.

To learn more, see paymentAmount.

itemFeeAmount

Indicates the total cost of all items in an order.

To learn more, see itemFeeAmount.

takeawayFeeAmount

Indicates the takeaway charge.

deliveryFeeAmount

Indicates the delivery fee to be charged on delivery orders, that is, when the value of orderType is DELIVERY.

convenienceFeeAmount

Indicates the convenience fee to be charged on pickup orders, that is, when the value of orderType is PICKUP.

smallOrderFeeAmount

Indicates the fee to be charged on orders less than the minimum order amount.

To learn more, see smallOrderFeeAmount.

Calculate order totals

paymentAmount

The following formulas explain how paymentAmount is calculated:

  • orderOriginalAmount = itemFeeAmount + takeawayFeeAmount + deliveryFeeAmount + convenienceFeeAmount
    • When the value of orderType is DELIVERY, no convenienceFeeAmount is charged, which means orderOriginalAmount is the sum of itemFeeAmount, takeawayFeeAmount, and deliveryFeeAmount.
    • When the value of orderType is PICKUP, no deliveryFeeAmount is charged, which means orderOriginalAmount is the sum of itemFeeAmount, takeawayFeeAmount, and convenienceFeeAmount.
  • orderTotalAmount = orderOriginalAmount + smallOrderFeeAmount
  • paymentAmount = orderTotalAmount - discountAmount
    • This formula means paymentAmount is equal to orderTotalAmount minus any discounts.
    • discountAmount indicates the reduced amount. The amount can be reduced by applying coupons invested by our server or the merchant.

itemFeeAmount

The following formulas explain how itemFeeAmount is calculated:

  • singleItemFeeAmount = (rootItem.price + addOnItem.price * addOnItem.quantity) * rootItem.quantity
  • itemFeeAmount = Sum{singleItemFeeAmount}

For example, as shown in the sample request in the createOrder API:

  • The saleAmount of itemId 11010 is 869 and its quantity is 1;
  • The saleAmount of itemId 11011 is 10 and its quantity is 2;
  • The saleAmount of itemId 11012 is 300 and its quantity is 2;

So itemFeeAmount = (869+10*2)*1+300*2 = 1489.

smallOrderFeeAmount

The following explains how smallOrderFeeAmount is calculated:

  • If orderOriginalAmount is greater than or equal to thresholdAmount, it returns 0, which means no smallOrderFeeAmount is charged.
  • If orderOriginalAmount is less than thresholdAmount, the formula is Math.min(maxAmount, (thresholdAmount-orderOriginalAmount)). There are two scenarios you can expect:
    • If thresholdAmount minus orderOriginalAmount is greater than or equal to maxAmount, smallOrderFeeAmount is equal to the value of maxAmount.
    • If thresholdAmount minus orderOriginalAmount is less than maxAmount, smallOrderFeeAmount is equal to thresholdAmount minus orderOriginalAmount.

For example, as shown in the sample request in the updateVendorInfo API, maxAmount is 3 and thresholdAmount is 10.

  • When orderOriginalAmount is greater than or equal to 10 SGD (minimum order amount), no smallOrderFeeAmount is charged.
  • When orderOriginalAmount is less than 10 SGD:
    • If orderOriginalAmount is 4 SGD, smallOrderFeeAmount is 3 SGD.
    • If orderOriginalAmount is 7 SGD, smallOrderFeeAmount is 3 SGD.
    • If orderOriginalAmount is 8 SGD, smallOrderFeeAmount is 2 SGD.