How to create a Wish List / liked items

I’ve read the other posts and I cannot find the answer.

I’ve tried to decipher the wixData.insert but I do not understand it either. Can someone explain it a different way?

OnClick (button or a heart image) i want User be able to ‘like’ an item. The button/image will be located on a dynamic item page. Items will be displayed in a table (dynamic member page) so that member can scroll through the table, click on the item and be redirected back to the dynamic item page.

So here is mockup of what it should look like … now … how do i get it to work? lol

Please?

(It doesn’t have to be a table. It can be a gallery. I just want the overall flow to be as mentioned above.)

P.S. This is NOT an actual store — ‘order’ button redirects to external URL. Not sure if this mattered or not … just wanted to let you know just in case.

Hay Nayeli,

This is actually quite simple to do -

You have a collection of items. To have liked items we need to have another collection of liked items, that includes two fields - liked item id, and the liking user (can be the _owner field).

Given this setup - for instance -

collection items
  (_id)
  title
  display name
  product url
  description
  image

collection liked_items
  likedItemId - of type reference to items
  (_owner)
  permissions - members can write, author can read

On the item page, add a like button, that inserts a liked item to the liked items collection

export function BUTTON1_click() {
  // note that wix data adds automatically the _owner field 
  wixData.insert('liked_items', 
    {likedItemId: $w('DATASET1').getCurrentItem()._id});
}

on the wish list page, have a table connected to a dataset
Set the dataset to read the liked_items collection. Because we have set the field type of likedItemId as reference, you can now use all the fields from items in the same table - you will just need to add them using add columns / add fields to the table.

ok … i will try this in the morning … thank you :slight_smile:

Hello Yoav,

The instructions you gave me above worked marvelously. Thank you VERY much for that. Now … I was trying to take it one step forward … and prevent duplicates from being added to the page AND at the same time prompt user to login if they were not already signed in. I basically tried to get an idea of how to create the code from the ‘member profile’ article … but … lol … well, no success so far.

While it has ZERO visible ‘errors’… I know there are plenty because it’s not working. Could you help point me in the right direction again? Thank you :slight_smile:

(I have it saved as wishlist2 in my account, just in case you wanted to take a look)

.

Hii… miss Nayeli…
I don’t know anything about coding…i want to add wishlist to my wix website…
i tried to do as mentioned above…but i don’t know anything about it…please help me out about this…as wishlist is a very imp. feature.
Please guide me in a simple way.
I have seen ur tutorial video on youtube…but even can’t understand the first step.

Yo code queen, u got a solution for this