S
S
sudo-AndrewSmith2020-10-23 12:53:41
JavaScript
sudo-AndrewSmith, 2020-10-23 12:53:41

I can't fix the redirect, are there any JS experts?

I got in touch with Viks here on my own and I don't understand how to solve one problem...

Task: It is necessary to make some of the products redirect to another page.

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

Question:
Perhaps someone worked with this miracle designer and knows How to solve this problem?

Perhaps someone knows how to make a page reload almost imperceptibly using JS? (there is an option to create a 301 redirect, but it only works after the page is refreshed, i.e. the user came to the page, updated it and got to the right 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')
   }
})

});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question