Skip to content
Docs
Get RestroPress

Filter

rpress_get_cart_discount_html

Updated
On this page

Filters the HTML for one applied discount in the cart totals.

Applied inside the loop of rpress_get_cart_discounts_html(), once per applied code. The default markup is a span with the generic label Discount, the discounted amount and a remove link that points to the checkout URL with the remove_cart_discount action. The output is later passed through wp_kses with a restricted set of tags, so unsupported tags and attributes are stripped on the checkout page.

Parameters#

ParameterTypeDescription
$discount_htmlstringThe HTML for this discount.
$discountstringThe discount code.
$ratestringThe formatted discount rate for the code.
$remove_urlstringURL that removes the discount from the cart.

Return value#

string. The HTML for this discount.

Example#

function my_discount_html( $discount_html, $discount, $rate, $remove_url ) {
	return '<span class="my-discount">' . esc_html( $discount ) . ' (' . esc_html( $rate ) . ')</span>';
}
add_filter( 'rpress_get_cart_discount_html', 'my_discount_html', 10, 4 );

Source#

Applied in:

  • includes/discount-functions.php (line 824), in rpress_get_cart_discounts_html()

See also#

Was this page helpful?