You are here

public function WishlistProvider::getWishlistId in Commerce Wishlist 8.3

Gets the wishlist entity ID for the given user.

Parameters

string $wishlist_type: The wishlist type ID.

\Drupal\Core\Session\AccountInterface $account: The user. If empty, the current user is assumed.

Return value

int|null The wishlist entity ID, or NULL if none found.

Overrides WishlistProviderInterface::getWishlistId

2 calls to WishlistProvider::getWishlistId()
WishlistProvider::createWishlist in src/WishlistProvider.php
Creates a wishlist entity for the given user.
WishlistProvider::getWishlist in src/WishlistProvider.php
Gets the wishlist entity for the given user.

File

src/WishlistProvider.php, line 138

Class

WishlistProvider
Default implementation of the wishlist provider.

Namespace

Drupal\commerce_wishlist

Code

public function getWishlistId($wishlist_type, AccountInterface $account = NULL) {
  $wishlist_id = NULL;
  $wishlist_data = $this
    ->loadWishlistData($account);
  if ($wishlist_data) {
    $search = [
      'type' => $wishlist_type,
    ];
    $wishlist_id = array_search($search, $wishlist_data);
  }
  return $wishlist_id;
}