Back to PhocacartWishlist class

Method removeItem

public
removeItem
(mixed $id = 0)

Method removeItem - Source code

public function removeItem($id = 0)
{
    if ($id > 0) {
        if (isset($this->items[$id]) && (int) $this->items[$id] > 0) {
            if ($this->user->id > 0) {
                if (isset($this->items[$id]['product_id']) && isset($this->items[$id]['category_id'])) {
                    $db = Factory::getDBO();
                    $query = ' DELETE ' . ' FROM #__phocacart_wishlists' . ' WHERE product_id = ' . (int) $this->items[$id]['product_id'] . ' AND category_id =  ' . (int) $this->items[$id]['category_id'] . ' AND user_id =  ' . (int) $this->user->id;
                    unset($this->items[$id]);
                    // Because of ajax
                    $db->setQuery($query);
                    $db->execute();
                    return true;
                } else {
                    return false;
                }
            } else {
                unset($this->items[$id]);
                $session = Factory::getSession();
                $session->set('wishlist', $this->items, 'phocaCart');
                return true;
            }
        } else {
            return false;
        }
        return false;
    }
    return false;
}