Hi Dima.
I know you’re trying to make it work and it’s frustrating that it doesn’t yet. It’s like that sometimes with customizations. I’ll do what I can to help you, k? But let me first ask you a few things so we have a clearer picture.
I read the thread in the page you linked to. So you want to hide the link to a certain product if the user doesn’t have the required access, is that right?
Well, if you do it with JavaScript, a savvy user would be able to still get the link, because it’d have already been served to the browser and then JS just hides it. It could be done, you can look at s2’s variables in the JS to check the user’s access and write your JS to hide the link or not. See: WP Admin > s2Member > API / Scrpiting > JS/API Globals and PHP/API Constants
It’s also possible, and generally much better, to just not send the link at all to the browser. You can customize your link with a conditional that checks the user’s access, and adds the link based on that. If your WooCommerce page allows shortcodes, you can use the s2If shortcode. If you can use PHP, then it’s possible with a PHP condition, of course. See: https://s2member.com/kb-article/s2if-simple-shortcode-conditionals/
The queries thing you saw in the s2 code, is related to this restriction: WP Admin > Restriction Options > Alternative Views
Does that help? 