Hide/Show Price if User is Logged In

Hello, I know that Wix Store is now working with wix code. I am hoping to change the visibility of my store’s prices using wix code. Previously my store was set to hide prices on the products gallery and only a member could access the store product pages to view the prices and make purchases. The problem with this is I had to turn off the products quick view because the price was visible there without being logged in. I would also like the prices to be visible on the product galleries to members that are logged in and not only visible on the product pages.

I started the code as follows but I’m really unsure of how to code the price to show or hide:

import wixUsers from ‘wix-users’;
import wixStores from ‘wix-stores-backend’;

$w.onReady(() => {
if (wixUsers.currentUser.loggedIn) { (From below********** I know it is wrong)
wixStores.price.show(“price”);
} else {
wiStores.price.hide(“price”);
}
} );

Any advice on how to correct the code to show/hide price in the product galleries based on a member being logged in or not would be much appreciated. Also should I add this code to each individual store page that is displaying a collection or should I add it once to the site? Thank you!

Hi did you manage to find out the code for this?

Choose to hide on load the elements with the prices.
Create a condition that checks if a user is logged in then show the prices.

For more information:
https://www.wix.com/code/home/example/Hide-and-Show-Elements
https://www.wix.com/code/reference/wix-users.html#currentUser

Oh and by the way, you are missing a ‘x’ on this line: ‘wiStores.price.hide(“price”);’

Although it should really be something like this:
$w(‘#price’).hide(); or $w(‘#price’).show();

the other problem s it doesn’t see the price as a element so (’ #price ') is not recognized

Any Solutions Guys ?