Hi,
My visitors on the site click on a button to choose the designs they like, this gets inserted as a Boolean into a Database Collection “ChooseDesign”. I want to capture the visitor User Id and the path of the page where they have chosen design. Every design is a dynamic page.
I am trying to use before Insert hook. Here is the code snippet I am using on data.js of the hook function. The user input - boolean is getting inserted. But however I try the UserId and the path is always NULL. Can someone please help me?
import function wixUsers from ‘wix-user’;
import function wixLocation from ‘wix-location’;
export function ChooseDesign_beforeInsert(item,context) {
let UserId = wixUsers.currentuser;
let DesignId = wixLocation.url;
item.User = UserId;
item.Design = DesignId;
return item;
}