Addonify Wishlist Object
The plugin provides with an object that can be used to perform all server side operations in wishlist. Object is created using singleton design pattern. Object is available globally and you can use it as:
global $adfy_wishlist;
Methods available in the object are listed below:
/** * Save product in wishlist. * * @param int $product_id Product ID. * @param int $wishlist_id Wishlist ID (Optional) (If not provided, default wishlist id is used. Useful when multi wishlist option is disabled). * @return boolean True if saved, false otherwise. */ function add_to_wishlist( $product_id, $wishlist_id = false )
/** * Remove product from the wishlist if product is already in the wishlist. * * @param int $product_id Product ID. * @param int $parent_wishlist_id Wishlist ID (Optional) (If not provided, default wishlist id is used. Useful when multi-wishlist option is disabled). * @return boolean true if removed successfully otherwise false. */ function remove_from_wishlist( $product_id, $parent_wishlist_id = false )
/** * Check if product is in wishlist. * * @param int $product_id Product ID. * @return boolean True if product is in wishlist, false otherwise. */ function is_product_in_wishlist( $product_id )
/** * Check if product is in mentioned wishlist. * * @param int $wishlist_id wishlist ID. * @param int $product_id Product ID. * @return boolean True if product is in wishlist, false otherwise. */ function is_product_in_this_wishlist( $wishlist_id, $product_id )
/** * Get default wishlist id. * * @return int */ function get_default_wishlist_id()
/** * Get wishlist items. * * @return array */ function get_wishlist_items()
/** * Get wishlist items count. * * @return int */ function get_wishlist_items_count()
/** * Vacate wishlist. * * @param int $wishlist_id Wishlist ID (optional) (If not provided, default wishlist id is used. Useful when multi wishlist option is disabled).. * @return bool True on success, false otherwise. */ function empty_wishlist( $wishlist_id = false )
Use is simple and very straight forward:
// for fetching all wishlist items. global $adfy_wishlist; $wishlist_items = $adfy_wishlist->get_wishlist_item();