Can't fix the redirect, do you have JS specialists?

  • 0
    I got involved here on my own with Weeks and I don't understand how to solve one problem ...

    Task: We need to make sure that some of the products are redirected to another page.

    So far, I have temporarily solved this problem by Redirect, but the whole point is that when the user clicks back, he finds himself in some kind of "redirect cycle", i.e. gets to the page from which I'm redrawing, and, accordingly, redirect again and so in a circle ... ( here is an example , carbon products at the beginning - click back and feel it)

    Question:
    Perhaps someone worked with this wonderful designer and knows how to solve this problem?

    Maybe someone knows how to do an almost invisible page reload using JS? (there is an opportunity to create a 301 redirect, but it only works after refreshing the page, i.e. the user came to the page, updated it and got to the desired one, but there are no problems with clicking back)

    Here is the redirect code:
    import wixLocation from 'wix-location';
    
    	$w.onReady(function () {
        $w('#productPage1').getProduct()
        .then( (product) => {
    	 if(product._id === '18837fe4-787c-46bb-8c1d-9dcf0b322294') {
    		 $w('#productPage1').hide()
    		 $w('#group1').hide()
    	     wixLocation.to('/carbon');	 
    	 }
    	 else if (product._id === '4663b6cd-0297-4125-8d4f-dcf61d73b467') {
    		  $w('#productPage1').hide()
    		 $w('#group1').hide()
    	     wixLocation.to('/label');
    	 }
    	  else if (product._id === 'b696e3e2-5a90-d84e-7ebb-d51b7b47ae46') {  //geilik4x4 store (main page)
    		  $w('#productPage1').hide()
    		 $w('#group1').hide()
    	     wixLocation.to('/gelik4x4');
    	 }
    	 	  else if (product._id === 'd7a7eb5d-3a60-263f-b2bb-850f125d2c99') { //geilik6x6 store (main page)
    		  $w('#productPage1').hide()
    		 $w('#group1').hide()
    	     wixLocation.to('/gelik6x6');
    	 }
    	 	 else if (product._id === 'fa563ab3-607a-9eef-fa89-ea2743e37879') { //carbon store (main page)
    		  $w('#productPage1').hide()
    		 $w('#group1').hide()
    	     wixLocation.to('/carbon');
    	 }
    	 	else if (product._id === 'a44fa427-cdfd-331f-6f8a-f27d033bd4a7') { //label store (main page)
    		  $w('#productPage1').hide()
    		 $w('#group1').hide()
    	     wixLocation.to('/label');
    	 }
    	 else{
    		 console.log('done')
    	 }
    })
    
    });
    JavaScript Anonymous, Dec 9, 2020

  • 0 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!