URL Redirects & Velo Javascript

Problem: URL redirects don’t work unless the page is accessed directly (or browser is refreshed), as I believe Javascript is doing some sort of request or “Promise” with Velo.

  • Example: websitedomaindotcom/products
  • Click on a product (websitedomaindotcom/product-page/candle/) - a redirect already exists (websitedomaindotcom/product-page/candle/ TO newwebsitedomaindotcom/product/candle/)
  • BUT website loads old URL
  • Refresh the page, THEN it redirects to new page

How do I disable this Velo thing, or at least the portion that “ajax” loads the page so it’s a standard HTTPS request?

Product:
The site is on the standard Wix Editor.

Getting such issues, are in most cases cause by the following …

a) You do not wait for your PAGE to be ready first
b) You do not wait your DATASET to be ready first (if dataset is in usage)
c) You do not use → ASYNC-AWAIT (wrong handling of promises)
d) making a request and getting a responseFETCHING DATA ← should also run ASYNCHROUNOUS.

Example: ( a )

$w.onReady(()=>{console.log('Page is ready!!!');

});

Example: ( b )

$w.onReady(()=>{console.log('Page is ready!!!');
    $w('#myDatasetIDHere').onReady(()=>{console.log('Dataset is ready!');
 
    });
});

Example: ( c )

$w.onReady(()=>{console.log('Page is ready!!!');
    $w('#myDatasetIDHere').onReady(async()=>{console.log('Dataset is ready!');
         const results = await start_myAsynchronousFunction();
    });
});

async function start_myAsynchronousFunction() {
    console.log('..my function started...');     
}

The same princip for http-requests!

And there is another usecase if you refresh a dataset → dataset.refresh() <—

1 Like

Your response was detailed, but unhelpful. How do I make the URL redirects work and disable the page pre-loading (or whatever it’s doing)?

Yes, as most as possible detailed, without even knowing your → CODE <–, since you even did not provide your current running code !!!

You are asking inside the → CODE-SECTION <–, right?

WHERE IS YOUR CURRENT ISSUED CODE?

You also did not describe what exactly you are doing and how looks like your SETUP!
You also did not mention that you are working with Wix-Stores.

You are asking out of → NOWHERE ← but you are expecting an absolute detailed SOLUTION!

Maybe we first should learn how to describe your issued situation in detail and maybe add some images → and then ask for help!

And maybe you are just a AI-generated questioner → since you even do not have a NAME!
2025-01-25 19_30_49-Window

-------> So many → MAY-BEES <— and no real facts!

1 Like

It’s a Wix site. Just a basic website with products. I don’t think it’s that complicated.

Your hostility is off the charts!

It is not my hostility, it is more how much efforsts you make → to get a valuable answer.
Just to ask a question, generated in 5 sec. without any details → and then expecting a one-shot solution (for free) :thinking:

But i know such persons like you! And i teach them how to do it better!

Sorry again → MY HOSTILITY!

1 Like

I suppose I’m not asking the right questions then. I know very little about the Wix editor (I’m used to Wordpress/woocommerce). I also know literally nothing about Velo, and very little about JS. What do you need?

Now we are on the right track!

Ok! Question…

  1. Do you use CODE in your setup?

a) If not → show your setup (pics) → describe your process-flow.
b) If you have already integrated some code on your site, related to your issue → show show it.

Your description could/should be like…

  1. When i am on my Product-Page, i do the following action + (pic)
  2. But when i do the action → something goes wrong.
  3. I did setup a redirect → pic of showing how you exactly did it
  4. Since i am not using CODE → i will present my SETUP in PICS and describe which elements are involved…

used-elements…
-button (id)
-dataset(dataset-id)

process-flow…

  1. my process starts with
    2)…
    3)…
    4)…
  2. and ends with the issue that i get a wrong redirection and it only works after refresh.

ADDITIONAL:
I have implemented some → CONSOLE-LOGS ← which maybe could help to solve the issue.

Ok, and now slowly!

  1. I understand that you are not familiar with wix.
  2. But you should udnerstand, that only you see your generated SETUP in front of you.
    If you would have done everything by code → you just would have to show your code → so it would be easy to detect the issue very fast by code-investigation.
    But since you do not use code and anybody can really see how you have contructed your setup, it is difficult to imagine what is going on, on your side.
  3. This is why a more detailed description (including pics) would surely help much more to solve your problem.

You can also try to solve it on your own → by implementing some console-logs into your setup.

How to do?

  1. You activate the DEV-MODE (developer-mode) in your wix-editor ( already done? );
  2. You navigate to your product page (i asume that the product page is our starting point).
  3. Since you started the dev-mode, you now see more options in your wix-editor → now you are not only a DESIGNER, but also a → PROGRAMMER.

Let’s do some investigations…

  1. Add the following CODE into your Product-page…
$w.onReady(async function() {
    $w('#productPage1').onReady(()=>{
        get_myProduct();
    });
});

function get_myProduct() {
    $w('#productPage1').getProduct()
    .then(async(product) => {
        console.log("Product: ", product);
    });
}

This should show you the current data of your product inside the console.
Try this first and show what you get…

If this information is not enough… take a look here…

…there you will find the full code of how to get PRODUCT-DATA logged into your CONSOLE.

How to use → CONSOLE <— ???

If you are using → GOOGLE-CHROME → PRESS-F12 ← and navigate to console.

Investigate the results.

1 Like

I will dig into this and see what I can find. Thank you!

1 Like

Take your time and read carefully, or provide pisc of setup and describe each step from start to end.

I feel like this is more of a “I had an old domain, connected a new domain but my old domain is still being displayed in the browser bar” sort of question instead of a Velo issue where you actually wrote Velo code gone wrong.

Based on what you show here…

If so, you need to swap the domain as main vs secondary.

If not, post a screenshot of your code and/or a video to better visualize what you are trying to articulate.

2 Likes

Thanks for the suggestion @codequeen , but it’s not quite that.

OLD domain: hosted with Wix
NEW domain: hosted on another server

I put this screen capture together. Does that make more sense?

EDIT: uploaded somewhere else for easy viewing

I also put the code you mentioned in my product page:

But this is what it says:

What am I missing?

My fault! → There was 1 → onReady too much!
2025-01-25 22_05_11-Window

Try this…

$w.onReady(async function() {
    get_myProduct();
});

function get_myProduct() {
    $w('#productPage1').getProduct()
    .then(async(product) => {
        console.log("Product: ", product);
    });
}

Take a look onto the REPLY of → CODE-QUEEN!

1 Like

Thanks @CODE-NINJA ! Now I have a JSON table of data. Can I use some of that data along with Velo functions now to “turn off” the way the browser requests the URL?

Did you already read this … the additional post, i gave you?

Now → UPGRADE YOUR CODE…

function start_Process() {
    $w('#productPage1').getProduct()
    .then(async(product) => {console.log("Product: ", product);
        let productName = product.name; console.log("Product-Name: ", productName);
        let productDescription = product.description; console.log("Product-Description: ", productDescription);
        let currency = product.currency; console.log("Currency: ", currency);
        let discountedPrice = product.discountedPrice; console.log("Discounted-Price: ", discountedPrice);
        let inStockAvailability = product.inStock; console.log("In Stock available: ", inStockAvailability);
        let inventoryItemId = product.inventoryItemId; console.log("Inventory-Item-ID: ", inventoryItemId);
        let productImage = product.mainMedia; console.log("Product-Image: ", productImage);
        let productMediaItems = product.mediaItems; console.log("Product-Media-Items: ", productMediaItems);
        let productPrice = product.price; console.log("Product-Price: ", productPrice);
        let productPageURL = product.productPageUrl; console.log("Product-Page-URL: ", productPageURL);
    }).catch((error)=>{console.error(error);});   
}

Check all data and see if you already have found something, you can use, if not → investigate more…

Once you understand the PRODUCT-PAGE → maybe you will get a better OVERVIEW and an IDEA what to do to be able to resolve your issue.

@CODE-NINJA no, I did not see that I could expand the quoted post. Taking a look now.

EDIT: it won’t let me post more than 20 times so I’m replying here.

@CODE-NINJA I’m not sure that post is applicable, except for getting the JSON data the console provides. Did you watch the screen capture I made? That clearly describes my issue, but perhaps I’m missing something?

EDIT 2:

Yes! That would work! Hmm, how do I do that @CODE-NINJA ??

What about →
let productPageURL = product.productPageUrl; console.log("Product-Page-URL: ", productPageURL);

What is the RESULT ?

There is surely more included data, you can get out of the LOG.
Check the main-log → console.log("Product: ", product);

UPGRADE your CODE → so you expand all logs and see everything what a PRODUCT-PAGE offers you.