// Código para personalizar la tienda de productos en Wix con Velo
import wixData from 'wix-data';
import wixLocation from 'wix-location';
$w.onReady(function () {
loadCategories();
$w("#categoryDropdown").onChange((event) => {
filterProducts(event.target.value);
});
});
function loadCategories() {
wixData.query("Categories")
.find()
.then((results) => {
let options = [{ label: "Todas", value: "" }];
results.items.forEach(category => {
options.push({ label: category.title, value: category._id });
});
$w("#categoryDropdown").options = options;
});
}
function filterProducts(categoryId) {
let filter = wixData.filter();
if (categoryId) {
filter = filter.eq("category", categoryId);
}
$w("#productsRepeater").data = [];
wixData.query("Products")
.filter(filter)
.find()
.then((results) => {
$w("#productsRepeater").data = results.items;
});
}
// Agregar botón de carrito a cada producto
$w("#productsRepeater").onItemReady(($item, itemData) => {
$item("#addToCartButton").onClick(() => {
// Lógica para agregar al carrito
console.log(`Producto agregado: ${itemData.title}`);
});
// Mostrar cinta de oferta si el producto tiene descuento
if (itemData.discount) {
$item("#offerRibbon").show();
} else {
$item("#offerRibbon").hide();
}
});
top of page
- Fragrancias -
No tenemos productos
para mostrar en este momento.
bottom of page