Wish list function

Hi all! I’m trying to create a wish list for educational courses on my website. However these courses aren’t listed in a store, they are just in a normal database displayed on a normal page and individual course details are displayed on a dynamic page.

This is the set up I currently have:

  • Course database with individual course details displayed on a dynamic page
  • Dynamic page has an add to wish list button
  • Once wish list button clicked, course details are entered into wish list database (as per code)
  • Wish list page displays course details. Filtered by owner = logged in member.
  • User can remove from wish list page by remove from wish list button (linked to wish list dataset and set to delete from database without code)

So everything is working great BUT I have 3 problems:

  1. If user A has wishlisted course A, then user B is unable to wishlist course A. I think it’s because it’s a duplicate? So how do I fix this?

  2. If user C wishlists course C, then on the wishlist page, user C will see course C and another blank repeater (an empty repeater box is created for every add to wishlist button click.)

  3. If the user is not logged in as a member, the add to wishlist button still works and they can still see their wishlisted courses on the wishlist page. However the remove from wish list button doesn’t work if they’re not logged in.

Thanks so much in advance for your help guys!

import wixData from 'wix-data';
export function button11_click(event) {
        let toInsert = $w("#dynamicDataset").getCurrentItem(); 
        wixData.insert("Favourites", toInsert) 
        .then( (results) => {
                console.log("Successfully added to favourites.")
                 $w('#text36').show()
        } )
        .catch( (err) => {
                let errorMsg = err;
                $w('#text40').show()
        } );
}

Firstly, if that is al the code on your page for this, then it is no surprise that a lot of it does not work correctly.

You need to add the onReady function for your page first of all.
https://www.wix.com/corvid/reference/$w.html#onReady

You mention a remove button, however that is nowhere in your code above.

If you want your wishlist to be only available for members only, then you need to check if the current user is a logged in site member or not. You don’t have that in your code above either so obviously it is going to be showing on your website to any user whether public user or a site member.

So you can’t use the Wishlist from Corvid tutorial as that is about wishlist for products in Wix Stores.
https://www.wix.com/corvid/example/wishlist

However, you can find a tutorial that will help you from Nayeli (Code Queen) here.
https://www.totallycodable.com/wix/corvid/wishlist-code-part-1-with-tutorial-video
Wix Wishlist - Part 1 Video
Wix Wishlist - Part 2 Video

Hi thanks for your reply! There’s no code for a lot of it because I’ve been using native wix functions e.g. The remove button has been linked to the wish list dataset/collection and I’ve set the click action to “delete”.

I would also actually prefer all users to be able to use the wish list function and not just members, and with the set up I’ve got everything works except for the 3 things I’ve mentioned.

Is it not possible to fix the things I’ve mentioned without starting from scratch? I’m looking at alternatives because I’ve tried the tutorials you linked in the past but each time I’ve tried it hasn’t worked… The repeaters would always come up blank on the wish list page. Thanks again.
Is it not possible to fix the things I’ve mentioned without starting from scratch? I’m looking at alternatives because I’ve tried the tutorials you linked in the past but each time I’ve tried it hasn’t worked… The repeaters would always come up blank on the wish list page. Thanks again. but each time I’ve tried it hasn’t worked… The repeaters would always come up blank on the wish list page. Thanks again.