Skip to content
Docs
Get RestroPress

Filter

rpress_get_cart_item_discounted_amount

Updated
On this page

Filters the discounted unit price of a cart item while its discount amount is calculated.

Runs in RPRESS_Cart::get_item_discount_amount() after the item's price has been reduced by the applicable discounts. The discount for the line is then computed as the original price minus the filtered value, so the value is the price after discount, not the discount itself.

Parameters#

ParameterTypeDescription
$discounted_pricefloatItem price after the applicable discounts.
$discountsarrayDiscount codes being applied.
$itemarrayThe cart line.
$pricefloatItem price before discounts.

Return value#

float. The price after discount.

Example#

function my_cart_item_discounted_amount( $discounted_price, $discounts, $item, $price ) {
	return max( 0, $discounted_price );
}
add_filter( 'rpress_get_cart_item_discounted_amount', 'my_cart_item_discounted_amount', 10, 4 );

Source#

Applied in:

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

See also#

Was this page helpful?