Forum

Thread tagged as: Members, Shop

How to dynamically hide products if the Member has a tag that matches the produc...

I'm looking for a way to dynamically hide a product from my product list if the member viewing the products has a Tag attached to them that matches the product SKU.

The idea being that each product on my site can only be purchased by the same Member/Customer Once.

So if a Member purchases a product. I want to pass a Tag onto that member that matches that of the product SKU.

Now when that member goes back to the list of products.. I'm looking for a way to hide all of the products that the member has already purchased. I know I can potentially do this by dynamically hiding all products that match the tags of the Member - but I'm just not sure how I would go about it.

Can someone help?

Richy Thomas

Richy Thomas 0 points

  • 4 years ago
P K

P K 0 points

If they are not logged in they will see all the products anyway, which makes it slightly odd UX.

If it was me, I wouldn't use tags because of human workload and error potential. I would instead look up their purchase history and find SKU that way. You could build an array of previous order items SKUs, then compare against when listing products. Or list all products, then hide the matched items using CSS or JS. The latter method might be useful if you wanted to optionally show the user items previously purchased, greying them out or something.

Or use tags like your original intention! Maybe put a class name matching the tag name/SKU on the HTML list item for each product, and hide those list items. Or something. Probably best to dive in and just try different things.

Hi P.K.

Products are only available to Members who are logged in. All of the products on the site are digital and only available if a Member has the criteria to be accepted onto the site in the first place.

The latter sounds like a good solution to me. But I'm unsure how to dynamically add a class onto each product item?