Hello
Sorry for my awful english. I did your tutorial https://www.wix.com/corvid/example/Wishlist .
And it works fine even if it’s not on a webstore. But there is an error that I cannot correct alone because I am starting with coding.
The ‘#loginMessage’ remains on the page after the user has logged in and you have to reload the page so that it disappears and the colorless heart becomes clickable
Do you have a code to correct this?
In advance thank you for your help
You need to post the code in context. Read our Community Guidelines on how to make a new post.
I hope to understand the request.
The code is your in your tutorial https://www.wix.com/corvid/example/Wishlist :
//-------------Page Setup-------------//
$w.onReady(async function () {
// Get the currently displayed product. product = await $w('#productPage1').getProduct();
// Check if the current product is in the wishlist and act accordingly. checkWishlist();
// Set the action that occurs when the login message is clicked to be the loginMessageClick() function. $w('#loginMessage').onClick(loginMessageClick);
});
and the loginMessageClick is :
// Set the action that occurs when the login message is clicked.
async function loginMessageClick() {
// Set the login options.
let options = {"mode": "login"};
// Hide the login message.
$w('#loginMessage').hide();
// Prompt the user to login using the options created above.
await wixUsers.promptLogin(options);
}
The page inviting to log in opens, but once the user has logged in, the page must be reloaded to function properly
If you are looking to hide the login button after login, use the following code. You will need to change the element ids according to your page.
import wixLocation from 'wix-location';
import wixUsers from 'wix-users';
$w.onReady( function () {
if(wixUsers.currentUser.loggedIn === true) {
$w('#loginButton').hide();
} else {
$w("#loginButton").show();
}
});
function loginButton_click(event) {
let options = {"mode": "login"};
wixUsers.promptLogin(options)
.then( () => {
$w("#loginButton").hide();
})
.catch( (err) => {
//an error occured
});
}
The examples are exactly that ‘examples’. If you want to customize it according to your needs you will need to do it yourself.
You need to have a basic understanding of javascript and corvid to understand the code and how it is functioning. The wishlist example is a intermediate one, start with basics to learn how to code.
Thanks for this help.
It is not exactly what I need.
I would like that when we click on the button “loginMessage” the code executes as it is already AND that the page, on which this button is, is reloaded
async function loginMessageClick() {
let options = {"mode": "login"};
$w('#loginMessage').hide();
wixUsers.promptLogin(options)
.then( () => {
let url = wixLocation.url;
wixLocation.to(`${url}`);
})
.catch( (err) => {
//error
});
}
Thank you so Much. Problem resolved
Maybe we should correct the tutorial https://www.wix.com/corvid/example/Wishlist : for other beginners?