I think that in order to get this to work you will have to add the code to open the second lightbox to the page code where you opened the lightbox originally. Technically once the lightbox is closed the page code for that lightbox is terminated. Meaning it would not see the line to open the second lightbox.
Since you can not open a lightbox while another one is already opened we can also not call that line of code before closing the existing lightbox. Therefore we have to have an intermediary to process the redirect successfully.
One thing you could try is passing a data object into the close function that contains the name of the second lightbox you would like to open. That would look something like this:
Lightbox page:
export function close() {
let newLightBox = "lightBox2"
wixWindow.lightbox.close({data: newLightbox});
}
Page code:
wixWindow.openLightbox("lightBox1)
.then((received) => {
wixWindow.openLightbox(received.data)
})
I have not tried this bit it should work based on the following recourses:
openLightbox - Velo API Reference - Wix.com
close - Velo API Reference - Wix.com
Also something cool is that the lightbox will not pass the data object back to the page if it is closed with the “X” or by clicking on the background. This makes the close function especially easy to bind to a button. You could also (in theory) have multiple lightboxes with the ability to go back or foreword to a previous lightbox.