I have multiple products in my store category “Pillows”. I have 3 different dynamic pages for this “Pillows” category. Let’s call them “DynamicPillowTemplate1”, “DynamicPillowTemplate2” and “DynamicPillowTemplate3”.
I created a page that features all my different pillow products. They are featured in a Repeater. The repeater calls all the elements perfectly. I’m also calling the product _ID for references at this time.
I’ve got 2 issues:
#1
When I click on the Product Title (my click event), it calls the proper product page but not the proper dynamic page. The same dynamic page is called for all products.
#2
When I’m on my product page and want to go back to the pillow product page, I either click on the back button or I click my shop/pillows menu to get back to the pillow product page. When back to the pillow product page, somehow, the Product Titles are no longer clickable. It only works the first time.
My code is based on the following links:
https://www.wix.com/corvid/forum/community-discussion/work-with-autocalculated-url-routes-of-dynamic-pages
https://www.wix.com/corvid/forum/community-discussion/still-cant-find-option-to-link-repeater-to-dynamic-page
https://www.wix.com/corvid/forum/community-discussion/resolved-linking-a-button-from-a-repeater-to-a-dynamic-page
Product page with Repeater
Code
import wixLocation from ‘wix-location’ ;
import { local } from ‘wix-storage’ ;
const linkField = $w( “#textProductID” ).text // replace this value
$w.onReady( function () {
$w( “#StoresProductsDataset” ).onReady(() => {
const numberOfItems = $w( “#StoresProductsDataset” ).getTotalCount();
$w( "#repeater1" ).onItemReady(($item, itemData, index) => {
$item( "#textProductName" ).onClick((event) => {
wixLocation.to(itemData[$item( "#textProductID" ).string]);
console.log( "ProductID: " + wixLocation.to(itemData[$item( "#textProductID" ).string]));
$w( "#StoresProductsDataset" ).getItems( 0 , numberOfItems)
.then((result) => {
const dynamicPageURLs = result.items.map(item => item[linkField]);
console.log( "Dynamic page: " + dynamicPageURLs);
local.setItem( ‘dynamicPageURLs’ , dynamicPageURLs);
})
. catch ((err) => {
console.log(err.code, err.message);
});
});
})
})
})
Console.log results
ProductID: undefined
Dynamic page: ,
Thank you