You are here

function commerce_wishlist_in_wishlist in Commerce Wishlist 7

Verify if this prodcut has been added to wishlist

3 calls to commerce_wishlist_in_wishlist()
commerce_wishlist_add_form_validate in ./commerce_wishlist.module
Validate callback for commerce_cart_add_to_cart_form().
commerce_wishlist_form_alter in ./commerce_wishlist.module
Implements hook_form_alter().
commerce_wishlist_operations in ./commerce_wishlist.module
Menu callback: Perform various actions (add to wishlist etc)

File

./commerce_wishlist.module, line 283
Provides the wishlist for use in Drupal Commerce.

Code

function commerce_wishlist_in_wishlist($uid, $product_id, $nid = NULL) {
  $conditions = db_and();
  $conditions
    ->condition('uid', $uid);
  $conditions
    ->condition('product_id', $product_id);
  if ($nid) {
    $conditions
      ->condition('nid', $nid);
  }
  $result = db_select('commerce_wishlist', 'cw')
    ->addTag('wishlist')
    ->fields('cw', array(
    'wishlist_id',
  ))
    ->condition($conditions)
    ->execute()
    ->fetchAssoc();
  return isset($result['wishlist_id']);
}