Skip to content
Docs
Get RestroPress

Action

rpress_cart_discounts_updated

Updated
On this page

Fires after the set of discount codes on the cart has changed.

Runs after a discount code is added (rpress_set_cart_discount) or removed (RPRESS_Cart::remove_discount, rpress_unset_cart_discount), once the session holds the new set of codes.

Parameters#

ParameterTypeDescription
$discountsarray|stringThe active discount codes.

Example#

function my_cart_discounts_updated( $discounts ) {
	$codes = is_array( $discounts ) ? $discounts : array_filter( explode( '|', (string) $discounts ) );
	RPRESS()->session->set( 'my_discount_count', count( $codes ) );
}
add_action( 'rpress_cart_discounts_updated', 'my_cart_discounts_updated', 10, 1 );

Notes#

When a code is set, $discounts is an array of codes; when a code is removed it is the remaining codes joined with the pipe character (a string).

Source#

Fired from:

  • includes/cart/class-rpress-cart.php (line 509), in RPRESS_Cart::remove_discount()
  • includes/discount-functions.php (line 682), in rpress_set_cart_discount()
  • includes/discount-functions.php (line 705), in rpress_unset_cart_discount()

See also#

Was this page helpful?