WordPress at a glance
function is not described

Automattic\WooCommerce\Admin\Features\Navigation

Favorites::add_item() public WC 1.0

Add item to favorites

{} It's a method of the class: Favorites{}

No Hooks.

Return

WP_Error|Boolean. Throws exception if item already exists.

Usage

$result = Favorites::add_item( $item_id, $user_id );
$item_id(string) (required)
Identifier of item to add.
$user_id(string|number)
Identifier of user to add to.

Code of Favorites::add_item() WC 5.3.0

<?php
public static function add_item( $item_id, $user_id = null ) {
	$user = $user_id ?? get_current_user_id();

	if ( ! $user || ! $item_id ) {
		return new \WP_Error(
			'woocommerce_favorites_invalid_request',
			__( 'Sorry, invalid request', 'woocommerce' )
		);
	}

	$all_favorites = self::get_all( $user );

	if ( in_array( $item_id, $all_favorites, true ) ) {
		return new \WP_Error(
			'woocommerce_favorites_already_exists',
			__( 'Favorite already exists', 'woocommerce' )
		);
	}

	$all_favorites[] = $item_id;

	self::set_meta_value( $user, $all_favorites );

	return true;
}