Filter
rpress_apply_preset_discount
On this page
Filters the preset discount code before it is applied to the cart.
Applied in rpress_apply_preset_discount() on init at priority 999. The code is read from the preset_discount session value, which is stored from a discount request parameter, and has already passed rpress_is_discount_valid(). After the filter, the returned code is applied with rpress_set_cart_discount() and the session value is cleared.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$code | string | The sanitized discount code from the session. |
Return value#
string. The discount code to apply.
Example#
function my_preset_discount( $code ) {
return strtoupper( $code );
}
add_filter( 'rpress_apply_preset_discount', 'my_preset_discount' );
Notes#
The validity check runs before the filter, so a replacement code is not validated here.
Source#
Applied in:
includes/discount-functions.php(line 953), inrpress_apply_preset_discount()
See also#
Was this page helpful?
