You are here

function uc_product_update_wishlist_item in UC Wish List 8

Same name and namespace in other branches
  1. 6 uc_wishlist.module \uc_product_update_wishlist_item()
  2. 7 uc_wishlist.module \uc_product_update_wishlist_item()

Update information about a specific item in current wish list.

1 call to uc_product_update_wishlist_item()
uc_wishlist_add_item in ./uc_wishlist.module
Adds an item to a user's wish list.

File

./uc_wishlist.module, line 381
Allows users to create public shopping/wish lists.

Code

function uc_product_update_wishlist_item($nid, $data = [], $qty, $wid = NULL, $wpid = NULL) {
  if (!$nid) {
    return NULL;
  }
  $wid = $wid ? $wid : uc_wishlist_get_wid();
  if ($qty < 1) {
    $wpid = $wpid ? $wpid : $data['wpid'];
  }
  else {
    db_update('uc_wishlist_products')
      ->fields([
      'qty' => $qty,
      'changed' => REQUEST_TIME,
    ])
      ->condition('wpid', $wpid)
      ->execute();
  }
  if (strpos(\Drupal::request()
    ->getRequestUri(), 'wishlist', 1) !== FALSE) {
    drupal_set_message(t('Your item(s) have been updated.'));
  }
}