You are here

function uc_wishlist_remove_from_wishlist_submit in UC Wish List 8

1 string reference to 'uc_wishlist_remove_from_wishlist_submit'
uc_wishlist_form_alter in ./uc_wishlist.module
Implements hook_form_alter().

File

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

Code

function uc_wishlist_remove_from_wishlist_submit($form, FormState $form_state) {
  $wishlist_manager = \Drupal::service('uc_wishlist.manager');
  $pid = $form_state
    ->getValue('nid');
  $wishlist_manager
    ->remove_product($pid);
  $node = Node::load($pid);
  $productTitle = $node
    ->get('title')
    ->getValue()[0]['value'];
  drupal_set_message(t('@product_title was removed from your wish list.', [
    '@product_title' => $productTitle,
    '@url' => Url::fromRoute('uc_wishlist.wishlist')
      ->toString(),
  ]));
}