DocumentationCartFunctions
Calculate Coupon Discount
amerta / Cart / calculateCouponDiscount
Function: calculateCouponDiscount()
calculateCouponDiscount(
coupon,subtotal):number
Defined in: amerta/theme/utilities/cart.ts:13
Calculates the discount amount for a coupon based on the subtotal.
Parameters
| Parameter | Type | Description |
| ------ | ------ | ------ |
| coupon | any | The coupon object containing discount information. |
| subtotal | number | The subtotal amount before discount. |
Returns
number
The discount amount to apply.
Example
const discount = calculateCouponDiscount(couponObj, 100);