You are here

function commerce_wishlist_product_remove_ajax in Commerce Wishlist 7.3

Ajax callback to handle deletion of wish list item.

Parameters

object $line_item: The wish list product line item.

object $account: The account.

1 string reference to 'commerce_wishlist_product_remove_ajax'
commerce_wishlist_menu in ./commerce_wishlist.module
Implements hook_menu().

File

./commerce_wishlist.module, line 804
Provides a wish list for use in Drupal Commerce.

Code

function commerce_wishlist_product_remove_ajax($line_item, $account) {
  $product_id = commerce_product_load($line_item->commerce_product[LANGUAGE_NONE][0]['product_id']);
  commerce_wishlist_product_remove_line_item($line_item, $account);
  $link = theme('commerce_wishlist_product_add_link', array(
    'product_id' => $product_id,
    'user' => $account,
  ));
  $commands = array(
    ajax_command_replace('a#add-wishlist-' . $product_id, $link),
  );
  ajax_deliver(array(
    '#type' => 'ajax',
    '#commands' => $commands,
  ));
}