@yisrael-wix .currentItem () from your code also replaced with .getCurrentItem () to make the binding work
@nikitamp3 Yeah - sorry about the misspell of getCurrentItem. Musta got dropped when I pasted.
@nikitamp3 Are you using the dataset that is connected to the Repeater?
@yisrael-wix Yes, there is a Products dataset connected to the repeater. Internal elements are not connected to values.
@yisrael-wix Now we need to understand why the same value is repeated instead of listing all the products in the collection and find all the Products variables from Wix Stores
@nikitamp3 Does it display all of the products when you run without the onItemReady() function?
@yisrael-wix Yes, if you use the standard functionality, then all products are displayed. But the task is to do this through the nameoo code in order to bind the values of all fields to the elements, and not just those allowed by Wix
@nikitamp3 Please post the URL and explain where (what page) and how to see this issue.
The page is published and avalible
www.domelounge. ru/collections/%D0%BB%D0%B8%D0%BC%D0%BE%D0%BD%D0%B0%D0%B4
@yisrael-wix This page should list all products in the collection. Their images, name, description, addionalfield, price
@nikitamp3 When I load that page in Preview, it comes up blank. I’m really sorry, but I don’t understand Russian. I don’t know what the datasets are for, I don’t know what’s in the database collections, and I really can’t understand what you are trying to do.
On the Live site, the page that you sent shows twelve of the same product. If you believe that you are connected to the correct dataset and that that dataset is connected to the correct database collection, then you should contact Wix Customer Care to report this issue and get assistance. Hopefully they have someone who can figure out the Russian.
If I understood correctly…
1. Create a dynamic page for the " Stores / Collections " database.
The dynamic page will automatically add a dataset that holds all the information for a single collection item .
2. Add a new dataset that is connected to " Stores / Products " database.
3. Add new filter to " Stores / Products " dataset like the image:
*Collections field includes current item from Collections item (dynamic dataset).
4. Connect the repeater to " Stores / Products " dataset and all the items informations to the relevant dataset field.
5. Add " onItemReady " function to the repeater.
6. Add click event to the " add to cart " button inside repeater item.
7. Create new function that use addproductstocart from wix-stores api to add item to cart.
8. Create click event to the addToCart button inside the onItemReady function: onClick > call addItemToCart() and pass the current item id.
*Note that if your item has options to choose from such as: color, size, etc. you will need to allow the user to select this information for each item individually and save this information to the item before you add the item to cart.
Code example:
import { cart } from 'wix-stores';
const products = [{
productId: '',
quantity: 1,
//>> An example if your a product has options <<
// productOptions: {
// choices: {
// Size: "Small",
// Color: "Red"
// },
// }
}];
$w.onReady(function () {
// Write your JavaScript here
// To select an element by ID use: $w("#elementID")
// Click "Preview" to run your code
});
/**
* Sets the function that runs when a new repeated item is created.
* @param {$w.$w} $item,
* @param {Object} itemData,
* @param {Number} index
*/
export function repeater1_itemReady($item, itemData, index) {
console.log(itemData)
$item('#addToCartButton').onClick(() => {
addItemToCart(itemData._id);
});
}
function addItemToCart(itemId) {
products[0].productId = itemId;
cart.addProducts(products)
.then((updatedCart) => {
// Products added to cart
const cartId = updatedCart._id;
const cartLineItems = updatedCart.lineItems;
console.log('Item added to cart')
})
.catch((error) => {
console.log(error);
});
}
Thank you very much for your participation.
"4. Connect the repeater to “Stores / Products” dataset and all the items informations to the relevant dataset field. "
up to this point, I have done so, but using standard methods I cannot transfer the value of the AdditionalField field from the product card in the Wix Store to the repeater (Additional information about the product) This is the solution I am looking for.
And also how to change the format of the cost of products from the Price or FormattedPrice field
Standart format: 300,00 rub
Needed format: 300 ₽
@yisrael-wix Good. Thank you very much for your participation. As a result, I will definitely update the information with the solution in this post.
@iloveditorx Oh my God! I am now trying all this and will write on the result a little later. I’m sure it will work! Thank you very much!



