Skip to content
Docs
Get RestroPress

Filter

rpress_merge_identical_cart_items

Updated
On this page

Filters whether adding an identical item raises the quantity of the existing cart line.

Runs in RPRESS_Cart::add(). When true, an item matching an existing line (same size, add-ons and instructions) increases that line's quantity; when false, a separate line is always added.

Parameters#

ParameterTypeDescription
$valueboolWhether identical items are merged; true by default.
$fooditem_idintMenu item (fooditem) post ID being added.
$optionsarrayCart options of the item being added.

Return value#

bool. True to merge into an identical line, false to add a new line.

Example#

function my_merge_identical_cart_items( $merge, $fooditem_id, $options ) {
	if ( ! empty( $options['instruction'] ) ) {
		return false;
	}
	return $merge;
}
add_filter( 'rpress_merge_identical_cart_items', 'my_merge_identical_cart_items', 10, 3 );

Source#

Applied in:

  • includes/cart/class-rpress-cart.php (line 369), in RPRESS_Cart::add()

See also#

Was this page helpful?