Im trying to start up a small business, and i for that to work, i need to have different product, and event catergories for each client.
Each client needs a separate dynamic page, displaying the products and event from their catergori, and ony theirs.
I have a page in CMS, with my clients information, and what catergori the client corosponds to, and with what else needs to be displayed on the dynamic page.
The number of events updates thrugout the year, and the product number may vary from client to client.
When i just put in a webshop section, i cant change the displayed catergori, using CMS, unfortunately.
I hope you understand what im meaning, and might have an idea or two. Anything helps here.
You can have access to the default product collection by enabling coding environment. Once done, you can create dynamic page using the product collection use the category collection to use filter.
Hello,
Thank you so much. I will give it a go, but sorry for all my spelling mistakes.
So, i have a dynamic site, for each of my clients. I then sell products and events for these clients, on the dynamic site. But ofc, i dont want products from another client to show up on another dynamic site. So i only want the products and events, from the collection/category, that i have choosen, to be shown.
For example:
I have this client, lets call it “Eksempel.”
The clients name is put under “KundeNavn.”
He wants to sell products. I create the products, and put them in the collection called “Eksempel” and put it under “KundeStoreKat.”
So i want all the products in that collection to be showed, but no other products.
And then repeat for the events.
I hope you know what i mean, and sorry for the crazy names, but im from Denmark, so everything is in Danish
I understood everything… Just one more question, are you selling using the Wix Store and Event App or using a custom shop or have another collection for products and events.
Update:
I have tried to use some Velo code, and somehow, i learned it. Sorry that it is in Danish. But google translate
This code works with the Events, and store. Events with a status other than “SCHEDULED” will be filtered away.
import wixData from 'wix-data';
$w.onReady(function () {
// Hent den aktuelle skole fra den dynamiske dataset
const currentSchool = $w('#dynamicDataset').getCurrentItem();
if (!currentSchool) {
console.error("Ingen data fundet for den aktuelle skole.");
return;
}
// Hent produkter baseret på butikskategorier
wixData.queryReferenced("Kunder", currentSchool._id, "kundeKat")
.then((result) => {
if (result.items && result.items.length > 0) {
console.log("Butikskategorier fundet:", result.items);
// Saml alle kategoriernes ID'er
const categoryIds = result.items.map((category) => category._id);
// Hent produkter fra samlingen "Products" baseret på kategorierne
wixData.query("Stores/Products")
.hasSome("collections", categoryIds)
.find()
.then((productsResult) => {
if (productsResult.items.length > 0) {
console.log("Produkter fundet:", productsResult.items);
$w('#repeater10').data = productsResult.items; // Sæt produkterne som repeater-data
$w('#repeater10').show();
} else {
console.warn("Ingen produkter fundet for de valgte kategorier.");
$w('#repeater10').hide();
}
})
.catch((err) => {
console.error("Fejl ved hentning af produkter:", err);
});
} else {
console.warn("Ingen butikskategorier fundet.");
$w('#repeater10').hide();
}
})
.catch((err) => {
console.error("Fejl ved hentning af butikskategorier:", err);
});
// Hent events baseret på eventkategorier
wixData.queryReferenced("Kunder", currentSchool._id, "kundeEventKat")
.then((result) => {
if (result.items && result.items.length > 0) {
console.log("Eventkategorier fundet:", result.items);
// Saml alle kategoriernes ID'er
const categoryIds = result.items.map((category) => category._id);
// Hent events fra samlingen "Events" baseret på kategorierne og status = SCHEDULED
wixData.query("Events/Events")
.hasSome("categories", categoryIds)
.eq("status", "SCHEDULED") // Tilføj filteret for status
.find()
.then((eventsResult) => {
if (eventsResult.items.length > 0) {
console.log("Events fundet:", eventsResult.items);
$w('#repeater9').data = eventsResult.items; // Sæt events som repeater-data
$w('#repeater9').show();
} else {
console.warn("Ingen events fundet for de valgte kategorier med status 'SCHEDULED'.");
$w('#repeater9').hide();
}
})
.catch((err) => {
console.error("Fejl ved hentning af events:", err);
});
} else {
console.warn("Ingen eventkategorier fundet.");
$w('#repeater9').hide();
}
})
.catch((err) => {
console.error("Fejl ved hentning af eventkategorier:", err);
});
});