Filter
rpress_cart_data
On this page
Filters the cart AJAX response before it is sent.
Runs in the reorder, add to cart, update cart items and remove from cart AJAX handlers. The array contains the rendered cart item, totals such as subtotal, total and cart_quantity, and the tax values when taxes are enabled. After the filter, any missing totals keys are filled in with the current cart totals.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$return | array | The response payload sent to the cart script. |
Return value#
array. The response payload.
Example#
function my_cart_data( $return ) {
$return['my_items_in_cart'] = rpress_get_cart_quantity();
return $return;
}
add_filter( 'rpress_cart_data', 'my_cart_data', 10, 1 );
Notes#
Fired from several AJAX handlers, each building a slightly different payload.
Source#
Applied in:
includes/class-rpress-ajax.php(line 320), inRP_AJAX::reorder()includes/class-rpress-ajax.php(line 1032), inRP_AJAX::add_to_cart()includes/class-rpress-ajax.php(line 1127), inRP_AJAX::update_cart_items()includes/class-rpress-ajax.php(line 1216), inRP_AJAX::remove_from_cart()
See also#
Was this page helpful?
