Currently getting this error
when running the following code
import wixWindowFrontend from 'wix-window-frontend';
import wixLocationFrontend from 'wix-location-frontend';
let product;
$w.onReady(function () {
initProductPage();
});
wixLocationFrontend.onChange((location) => {
let newPath = location.path;
if (newPath?.[0] === 'product-page') {
initProductPage();
}
});
async function initProductPage() {
product = await $w('#productPage1').getProduct();
$w('#productPage1').setAddToCartLabel('Request a Quote');
$w('#productPage1').onAddToCart(onAddToCartHandler);
}
async function onAddToCartHandler(resume, cancel) {
const data = await getProductInfo();
wixWindowFrontend.openLightbox('Request a quote', data)
.then((results) => {
cancel();
});
}
async function getProductInfo() {
const quantity = await $w('#productPage1').getQuantity();
const choices = await $w('#productPage1').getSelectedChoices();
const customText = await $w('#productPage1').getCustomText();
return {
product: product,
quantity: quantity,
choices: choices,
customTextFields: customText,
}
}
any idea on how to fix ?
Where did you find this command? â> setAddToCartLabel(âRequest a Quoteâ);`
- I could not find such an API-Command.
- And you never have imported a backend function with such a name.
So one more time the questionâŚ
Where does â setAddToCartLabel() <â come from ?
Maybe you were looking for â> https://dev.wix.com/docs/velo/api-reference/wix-ecom-backend/cart/stores-to-e-commerce-cart-conversion-table
So it is normal that you get this errorâŚ
1 Like
I understand! Youâre looking for a way to handle situations where customers might want a quote for a product instead of adding it directly to their cart.
Wix Stores doesnât have a built-in feature for this specific scenario, but here are a couple of approaches you can explore, keeping in mind that some users might prefer a clear choice between adding a product to the cart (in-stock) or requesting a quote (out-of-stock):
1. Conditional Buttons (Advanced)
- This approach requires some coding knowledge with Wixâs Velo development platform.
- You can create two buttons on your product page: âAdd to Cartâ and âGet Quote.â
- Use Velo to check the productâs stock level in real-time.
- Based on the stock availability:
- If the product is in stock, the âAdd to Cartâ button is visible, and the âGet Quoteâ button is hidden.
- If the product is out of stock, the âAdd to Cartâ button is hidden, and the âGet Quoteâ button becomes visible.
2. âGet Quoteâ Button and Contact Form (Simple):
- Add a custom button labeled âGet Quoteâ using the âButtonsâ element in Wix Editor. This approach works regardless of stock availability.
- Create a dedicated contact form in Wix Forms.
- When users click the âGet Quoteâ button, it can either:
- Pre-populate the contact form with relevant product information.
- Or, simply open the blank contact form for users to fill out with additional details about their quote request.
Thanks tried your second suggestion and works perfectly for now
1 Like