Hi.
I was able to create a flow where the user selects a product from a custom database collection with a button that sends the item's Name to a quote request form in a light box.
Things that I need:
1. Add multiple items (instead of selecting an item replacing the one that was selected previously)
2. Being able to submit the item Name along with the rest of the form. (since the item name is coming from a different dataset, submitting the Name to the Quote Request database is not possible.
(the website doesn't need the wix stores database as it's only for product quote requests)
Below are my codes for Product page with a custom collection dataset and the light box with the form that is connected to a different dataset for submission.
import wixWindow from 'wix-window';
$w.onReady(() => {
$w("#dataset2").onReady(() => {
$w("#productRepeater").onItemReady(($item, itemData, index) => {
$item('#cartButton').onClick(() => {
let item = $item('#dataset2').getCurrentItem();
wixWindow.openLightbox('Request A Quote', item)
});
});
});
$w.onReady(() => {
let theItem = lightbox.getContext(); //this is the item you took from page
let postID = theItem._id; // this is the field key for the item ID in the database collection
$w("#dataset3").setFilter(wixData.filter()
.eq("_id", postID) //we are now filtering to display only the item that matches this ID
)
.then(() => {
console.log("Dataset is now filtered");
})
.catch((err) => {
console.log(err);
});
});