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

Cart Discount Percent of Subtotal

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

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_subtotal = (cart->discount() / cart->subtotal()) * 100

Notes:

  • This is an immediate-execution single tag, not a form tag.
  • It reflects the current cart state when the template is rendered.
  • Returns 0 when the cart subtotal is zero, including on an empty cart. Otherwise it returns the unformatted percentage from the formula above.

Example

{exp:cartthrob:cart_discount_percent_of_subtotal}