How to Apply "Request a Quote" Functionality to All Products on Wix Store Product Page?

Hey guys,

I have a related issue, but I’d need a slightly different solution. I want to use the same logic, but the “request a quote” button should only appear for items in a particular product category. After some digging (Wix Stores "Products" Collection fields - Bug or flaw?), I now understand that I can’t check the product category from the “getproduct” function and would need to write a query. That’s where I need help: my coding abilities are limited.

If someone could help with that part, it would be greatly appreciated.

Here’s where I’m at:

import wixWindowFrontend from “wix-window-frontend”;
import wixLocationFrontend from “wix-location-frontend”;

let product;
const collectionId = “e8c7a925-69d0-6f44-3482-8e1d20ea6662”;

$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();
if (collections === collectionId) {
$w(“#productPage1”).setAddToCartLabel(“Contact us to purchase”);
$w(“#productPage1”).onAddToCart(onAddToCartHandler);
}
}

async function onAddToCartHandler(resume, cancel) {
const data = await getProductInfo();
wixWindowFrontend.openLightbox(“Contact us to purchase”, data).then((results) => {
cancel();
});
}

async function getProductInfo() {
const productQuantity = await $w(“#productPage1”).getQuantity();
return {
product: product,
quantity: quantity,
};
}