Restricting Non-Members from Viewing Product Prices

Hello,

I would like the product prices on my website to be visible only to users who are logged in. Can you help me with this?

Thank you,

You can achieve this only by usage of VELO-CODING.

Wix-Members-APP installed?
Wix-Stores is for sure installed.

Your coding steps…

  1. Checking for logged in user → getting the USER-ID / OWNER-ID.
  2. If NO-LOGGED-IN-USER found → modifying the PRODUCT-PAGE by hiding the prices.
  3. If LOGGED-IN → unhiding the prices.

I want to hide product prices from users who are not logged in on my website. I found the following code block:

import { authentication } from ‘wix-members-frontend’;
import wixLocation from ‘wix-location’;

$w.onReady(function () {
// Check if the user is logged in
const isLoggedIn = authentication.loggedIn();

if (isLoggedIn) {
    // If the user is logged in, enable the download buttons
    $w("#downloadButton").enable();
} else {
    // If the user is not logged in, disable the download buttons
    $w("#downloadButton").disable();
    authentication.promptLogin(options)
        .then(() => {
            console.log('Member is logged in');
        })
        .catch((error) => {
            console.error(error);
        });
}

});

However, the elements that display product prices on my site use a class instead of an id. I tried using the class name in this code, but the system doesn’t allow it, or I’m not using it correctly.

Do you have any information on this? How can I hide prices using a class name? Do I need to use Wix Code (Velo by Wix) for this?