DocumentationAmertaThemeUtilitiesCalculate discountFunctions

Calculate Discount

amerta


amerta / amerta/theme/utilities/calculate-discount / calculateDiscount

Function: calculateDiscount()

calculateDiscount(subtotal, appliedCoupon?): number

Defined in: amerta/theme/utilities/calculate-discount.ts:11

Calculates the discount amount based on the coupon and subtotal.

Parameters

| Parameter | Type | Description | | ------ | ------ | ------ | | subtotal | number | The order subtotal before discount. | | appliedCoupon? | Coupon | null | The coupon object to apply, or null. |

Returns

number

The discount amount.

Example

const discount = calculateDiscount(100, couponObj);