Unfortunately, the wix store product page is not customizable enough for our website needs. This is no issue as we have built our own product pages (only a few items to sell) with the respective cart links.
However, when viewing the cart, the product image contains a link to the ‘wrong’ product page (i.e. the old default one). We need to either remove this link or redirect each individual product to our own custom URL. Is there a way to do this?
2 Likes
Have you tried a repeater of maybe just using the 301 functions under SEO in the sites Dashboard and insert the product pages url and the new product page urls there?
Hi Andreas thanks for your response. I just tried and it redirects only when I type in the ‘wrong’ product page URL manually. The link on the cart page still leads to the ‘wrong’ page and it does not redirect.
Gabriel,
We had the exact same issue. Because the cart is actually an iframe hosted on a completely different server, there is no way for you to update the links for the items in the cart itself.
You could go the tricky route and go onto the product page, and use wixLocation.to(‘/your-new-product-slug’) to get redirect as soon as the page is ready.
Chris thanks a lot I used the wixLocation.to() to redirect all ‘wrong’ product pages to the correct custom page.
Heres the code for any others with the same problem:
import wixLocation from 'wix-location';
let x = wixLocation.path; //returns an array of ["product-page", "secondary-path"]
$w.onReady(function () {
//TODO: write your page related code here...
wixLocation.to('/'+x[1])
});
I used wixLocation.path to retrieve the current ‘wrong’ product page, which returns the array of the default product-page and URL, for example /product-page/1001 would return [“product-page”, “1001”]. I then made all custom product pages follow the same path without /product-page, i.e. wixstore.com/1001, and redirected to the correct path with wixLocation.to(), and only the secondary path URL.
Appreciate all the help guys!
Hi Gabriel, could you leave us the link to view your work online? I’m looking to do something similar and I’d like to see how your custom product page looks.
Thanks.
Thank you for providing the coding! I’m having the same exact issues as you were. I have about 13 products that I’m needing to redirect. Unfortunately, I’m having some trouble figuring out how to make the coding work. For example, here are two urls that I’m trying to redirect. I’m trying to get “/product-page/rapture” to redirect to just “/rapture”. I’m also trying to get “/product-page/habitual” to redirect to “/habitual”. Can you advise on how I could incorporate that into the coding you provided above?
I am facing the same issue in February 2020. This topic is from August 2018 and no proper solution has been given to this yet? So far the solution I have found is exactly the same as the one used by Gabriel.
// Page code
import wixLocation from 'wix-location';
let path = wixLocation.path;
// remove "/product-page/"
path.shift();
let toUrl = "/stores/products/" + path.join("/");
wixLocation.to(toUrl);
$w.onReady(function () {
// Code here
});
The problem is, the solution is really ugly and not optimal. The user arrives at the wrong page, the wrong page has to load almost entirely, only then is the user redirected. Not only is this ugly, it is also not efficient.
One and a half year later, is this still the only solution? I tried using the routers.js file and adding something like this (for tests purposes):
import {redirect} from 'wix-router';
export function product_page_Router(request){
return redirect("https://google.com");
}
But the code above don’t work and loading the standard product page never gets redirected to Google’s website. I believe my router function gets overriden by Wix’s standard routing function used by the standard product page.
Is there really no other approach than the hack me and Gabriel are using? It would be great if we could catch these requests early on on the backend and redirect them properly.