Hello, I’m Watanabe.
I am creating a cart system with velo.
The mechanism is as follows:
- Set the user ID at the start of the session
- When the value of the checkbox in the repeater on the “Products” page changes, add or delete the product data in the repeater to the “checkSystem” collection
- When the cart button is pressed, a popup is displayed and the value of the “checkSystem” collection obtained by wixdata.query (filtered by user ID) is displayed in the repeater
Until recently, this system was working without any problems. However, when I debugged it the other day, I noticed that it was not working properly.
Specifically, it is as follows:
- Although the product is added by pressing the checkbox on the “Products” page, it is reflected in the cart popup slowly, and the product is not added to the cart until a while has passed.
- For the same reason, sometimes the product remains in the cart popup even if the value is removed from the collection when the product is deleted.
- I used wixdata.query to pull out information from “checkSystem” on the “Products” page as a debug, but the data was reflected slowly.
- When I checked the collection, the addition and deletion itself was performed normally.
- It works normally in preview mode.
For these reasons, I personally think there is some problem with wixdata.query.
Could anyone give me some opinions on the reason and possible solutions?
Thank you.
$item("#checkbox1").onChange((event)=>{
if($item("#checkbox1").checked === true){
session.setItem("saving","yes")
$w("#button27").disable()
let checklist = {
"id":itemdata._id,
"title":itemdata.imageTitle,
"image":itemdata.image,
"userId":session.getItem("firstSession")
}
wixData.insert("checkSystem",checklist)
.then(()=>{
if (!session.getItem("firstTimePopup")) {
wixWindowFrontend.openLightbox("cartSystem")
.then(() => {
wixWindowFrontend.scrollTo(0,0)
refreshitem();
if (session.getItem("allclear")) {
$w("Checkbox").checked =false
session.removeItem("allclear")
}
session.setItem("firstTimePopup", "yes");
})
}
})