Question:
Hello! I have a website that is operating as a catalog to request quotes, rather than a store. I have found several tutorials online. However, none of the tutorials I have found indicate how to also the selected product options as part of the quote request in addition to just the product name.
Product:
wix editor
What are you trying to achieve:
I am using Wix Stores to create a catalog where users can request a quote. I am following the totally codable tutorial..
However, in addition to the product name and ID, I also need to store product Options to the page and submit the selected options as part of the quote request. In other words, on the product page I want to store the Product ID as well as the Product Options. And then on click I want to route to the /quote page where the data from the product page will be dynamically pulled in.
What have you already tried:
I currently have this code in place on the product page. I am trying to store both the product options (when the choice is selected) and the product ID (on button click) before routing to the /quote page. When I add in the onChoiceSelected code, it breaks the onClick code and the page no longer routes to /quote. I’m completely new to Velo so I’m sure there is some sort of syntax error, but I can’t figure out what.
import { session } from 'wix-storage';
import wixLocation from 'wix-location';
$w.onReady(function () {
$w("#productPage1").onChoiceSelected((selectedChoices) => {
let mySelectedChoices = selectedChoices;
session.setItem("productChoices", mySelectedChoices); // {color: "blue", size: "m"}
});
$w("#button1").onClick((event) => {
$w('#productPage1').getProduct()
.then((product) => {
let theProduct = product._id; //This line gets the ID of the current product
session.setItem("product", theProduct); //This line saved the product ID into session storage
})
.then(() => {
wixLocation.to("/quote"); //This line redirects you to the page with the request form
})
.catch((error) => {
console.log(error);
});
});
});
Additional information:
[Include any other pertinent details or information that might be helpful for people to know when trying to answer your question.]