Skip to content
Docs
Get RestroPress

Filter

rpress_ajax_pre_cart_item_template

Updated
On this page

Filters the cart item data before the cart item row markup is built in an AJAX response.

Runs in the reorder, add to cart, update cart items and cart item quantity AJAX handlers before rpress_get_cart_item_template() renders the row. The item is an array with id (menu item ID) and options (the cart item options, including quantity, add-ons and instruction).

Parameters#

ParameterTypeDescription
$itemarrayCart item data with the keys id and options.

Return value#

array. The cart item data to render.

Example#

function my_pre_cart_item_template( $item ) {
	if ( ! isset( $item['options']['instruction'] ) ) {
		$item['options']['instruction'] = '';
	}
	return $item;
}
add_filter( 'rpress_ajax_pre_cart_item_template', 'my_pre_cart_item_template', 10, 1 );

Notes#

Fired from several AJAX handlers; the item always has the same two keys id and options.

Source#

Applied in:

  • includes/class-rpress-ajax.php (line 297), in RP_AJAX::reorder()
  • includes/class-rpress-ajax.php (line 983), in RP_AJAX::add_to_cart()
  • includes/class-rpress-ajax.php (line 1079), in RP_AJAX::update_cart_items()
  • includes/class-rpress-ajax.php (line 1146), in RP_AJAX::cart_item_quantity()

See also#

Was this page helpful?