Skip to content
Docs
Get RestroPress

Filter

rpress_get_cart_discounts_html

Updated
On this page

Filters the combined HTML for all discounts applied to the cart.

Applied at the end of rpress_get_cart_discounts_html() after each discount has been rendered. The function returns early with no value when no discount is applied, so the filter does not run in that case.

Parameters#

ParameterTypeDescription
$htmlstringConcatenated HTML of all applied discounts.
$discountsarrayArray of applied discount codes.
$ratestringThe formatted discount rate of the last discount in the loop.
$remove_urlstringThe remove URL of the last discount in the loop.

Return value#

string. The combined discounts HTML.

Example#

function my_discounts_html( $html, $discounts, $rate, $remove_url ) {
	return '<div class="my-discounts">' . $html . '</div>';
}
add_filter( 'rpress_get_cart_discounts_html', 'my_discounts_html', 10, 4 );

Notes#

The $rate and $remove_url values come from the last loop iteration, so they are only reliable when one discount is applied.

Source#

Applied in:

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

See also#

Was this page helpful?