Filter
rpress_get_cart_item_discounted_amount
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#
| Parameter | Type | Description |
|---|---|---|
$discounted_price | float | Item price after the applicable discounts. |
$discounts | array | Discount codes being applied. |
$item | array | The cart line. |
$price | float | Item 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), inRPRESS_Cart::get_item_discount_amount()
See also#
Was this page helpful?
