Request a quote on product pages

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’);`

  1. I could not find such an API-Command.
  2. 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…
632ccc9b4ab714b25219f102fa0bd1c6298d230d_2_690x1161

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

We’ve also used the Request a Quote for Wix App, in case that makes things easier. We just add it to the site and can achieve the functionality you’re talking about for our clients.