Skip to content
Docs
Get RestroPress

Filter

rpress_get_cart_content_details_item_discount_amount

Updated
On this page

Filters the discount amount calculated for a cart line in the cart content details.

Runs in RPRESS_Cart::get_contents_details() for each cart line, after get_item_discount_amount() has produced the line's discount. The result is stored as the 'discount' of that line and feeds into subtotals and totals.

Parameters#

ParameterTypeDescription
$discountfloatDiscount amount calculated for the cart line.
$itemarrayThe cart line.

Return value#

float. The discount amount for the cart line.

Example#

function my_cart_item_discount( $discount, $item ) {
	return max( 0, round( $discount, 2 ) );
}
add_filter( 'rpress_get_cart_content_details_item_discount_amount', 'my_cart_item_discount', 10, 2 );

Source#

Applied in:

  • includes/cart/class-rpress-cart.php (line 213), in RPRESS_Cart::get_contents_details()

See also#

Was this page helpful?