CartThrob 10 documentation for ExpressionEngine commerce teams Visit CartThrob.com
CartThrob.com

Cart Discount Percent of Total

If coupons have been applied to the current cart, this outputs the value of that discount as a percentage of the total.

See also:

Parameters

This tag has no tag-specific parameters.

The tag returns an unformatted numeric percentage.

Behavior and Constraints

Code-backed calculation:

cart_discount_percent_of_total = (cart->discount() / cart->total()) * 100

Notes:

  • This is an immediate-execution single tag, not a form tag.
  • Output depends on the current cart totals at render time.
  • cart->total() already includes CartThrob total calculations (subtotal/tax/shipping/discount logic).
  • Returns 0 when the cart total is zero, including on an empty cart. Otherwise it returns the unformatted percentage from the formula above.

Example

{exp:cartthrob:cart_discount_percent_of_total}