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 [4]

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

Support [2]

  • Support & Discussion
  • Dealing with the cache plugins
  • Home
  • Kb
  • WooCommerce Wishlist
  • Developer
  • Useful Functions

Useful Functions

  • Updated on: January 27, 2023

Addonify Wishlist has defined some useful helper functions that you may want to use. The helper functions could be found inside inc/addonify-wishlist-helper-functions.php file.

Some of the helper functions are as follows:

// Function to get all wishlist items.
addonify_wishlist_get_wishlist_items();

// Function to get wishlist items count.
addonify_wishlist_get_wishlist_items_count();

// Function to check if a product is in wishlist. $product_id is optional.
addonify_wishlist_is_product_in_wishlist( $product_id = '' );

// Function to get add to wishlist button label. If $in_wishlist is set to true, added to wishlist button label will be returned.
addonify_wishlist_get_button_label( $in_wishlist = false );

// Function to get link to the wishlist page.
addonify_wishlist_get_wishlist_page_url();

Above functions about getting products, product count and checking if product is in wishlist only work when user is logged in as they are saved in database.

For non-logged-in users, wishlist data are saved locally. Following is a custom function in javascript available that you can use to obtain products in wishlist:

// Function to get all wishlist items.
addonify_wishlist_get_wishlist_products();

There are also custom JavaScript event triggers that you can use.

// addonify_added_to_wishlist fires after a product is added to the wishlist.
$(document).on('addonify_added_to_wishlist', function (event, [{ productID: $product_id, wishlist_count: $no_of_items_in_wishlist, sidebar_data: $html_appended_to_sidebar }]) {});

// addonify_added_to_wishlist fires after a product is removed from the wishlist.
$(document).on('addonify_removed_from_wishlist', function (event, [{ productID: $product_id, wishlist_count: $no_of_items_in_wishlist }]) {});

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