Manual

wishlist.class.php

wishlist class

Usage:

{{lang:php}}
// INITIALIZATION
// constructor new wishlist($db, $user_id[, $extra = '1']);
$WL = new wishlist($DB, $_SESSION['user_id'], 'cid = 3'); // $DB is the object from sql class, $extra sets additional condition to users id

// GET ALL WISHLISTS
$WL->get_wishlists(); // returns all user's wishlists (multidimensional array)
$WL->get_wishlists("datefield LIKE '2010-%'"); // optional extra condition

/*
 * Array (
 *  [0] => Array (
 *      [id] => 1
 *      [uid] => 1
 *      [name] => editor`s wishlist
 *      [furl] => editors-wishlist
 *      [datefield] => 2010-09-03 10:55:12
 *      [public] => 1
 *      [active] => 1
 *  )
 * )
 */

// CREATE WISHLIST
$WL->create_wishlist(); //creates new wishlist for user, named username`s wishlist
$WL->create_wishlist('My books'); //creates new wishlist for user, named My books

// MANAGE WISHLISTS
$WL->set_public(41); // sets wishlist ID 41 to public
$WL->set_public(11, false); // sets wishlist ID 11 to private
$WL->set_name(22, 'My music'); // sets name My music to wishlist ID 22
$WL->delete_wishlist(13); // deletes wishlist ID 13
$WL->get_user_id(23); // gets user's ID for wishlist ID 23

// WISHLIST'S ITEMS
$WL->get_items(12); //gets items for wishlist ID 12
$WL->get_items('my-music'); //gets items for wishlist by furl 'my-music'
$WL->add_item(1, 45); //puts market product ID 45 onto wihslist ID 1
$WL->remove_item(1, 45);
Try myPortal 2: