Skip to content
Addonify

Addonify

Documentation & knowledge based site

  • Docs
    • Quick View
    • Compare Products
    • Floating Cart
    • EDD 2Checkout Inline Gateway
  • Plugins
  • Themes
  • Support
  • Blog
Addonify store
  • Docs
    • Quick View
    • Compare Products
    • Floating Cart
    • EDD 2Checkout Inline Gateway
  • Plugins
  • Themes
  • Support
  • Blog

Getting started [2]

  • Installation
  • Access Setting Page

Developer [5]

  • Using Hooks
  • Overwriting Templates
  • Useful Functions
  • Custom Add to Wishlist Button
  • Addonify Wishlist Object

Support [3]

  • Support & Discussion
  • Dealing with the cache plugins
  • Changelog
  • Home
  • Kb
  • WooCommerce Wishlist
  • Developer
  • Addonify Wishlist Object

Addonify Wishlist Object

  • Updated on: April 13, 2023

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();

Didn't find what you looking for? Try sending your questions from our contact page.

Your feedback matters to us. Was this article helpful to you?

Copyright © 2022 addonify.com. All rights reserved.

Project by 💖 CreamCode.Org