Question:
How can I use JavaScript to redirect from a default dynamic product page to a custom dynamic product page derived from a different collection, where the custom page has the same name and link slug?
Product:
Wix Studio Editor
What are you trying to achieve:
I want to maintain functionality in the default store, but due to the minimal amount you can edit the structure of the default product page i have created my own and based it on a custom collection. I need to redirect users from the default product page to a specific page in my custom collection named “Product-Page-1”. Each item in this collection shares the same name and slug as on the default product page.
What have you already tried:
I used the following JavaScript code snippet but it’s not functioning as expected. I alos undertsnad that I can in theory use the tools once the site is published to re-direct users, but I have been specifically told not to pubish the site until its 100%.
Any help would be appreciated. I can give more details on the collections if neccicary but they are pretty standard. I also apologise if the answer is obvious.
import wixLocationFrontend from 'wix-location-frontend';
$w.onReady(async function () {
const product = await $w("#productPage1").getProduct();
console.log(product);
wixLocationFrontend.to(`/product-page-1/${product.slug}`)
});