need code / script for Sold Out product page redirect for Envy 33.8.0 theme.

Topic summary

A Shopify store owner using the Envy 33.8.0 theme needs a script to automatically redirect sold-out product pages to either the relevant collection page or homepage, with redirection stopping once items are back in stock.

Proposed Solution:
One responder provided a JavaScript snippet to add to either product.liquid or main-product.liquid files. The script:

  • Detects if the add-to-cart button is disabled (indicating sold-out status)
  • Redirects to the collection page if the user came from one, otherwise to the homepage
  • Requires customization based on specific theme structure

Current Status:
The store owner shared their store URL (lookandadorn.com) and uploaded their product.liquid file via Google Drive for review. Multiple responders offered to examine the theme structure and provide a tailored solution, noting that such customizations typically require individual store access to implement correctly. The discussion remains open as participants work toward a finalized, theme-specific implementation.

Summarized with AI on October 30. AI used: claude-sonnet-4-5-20250929.

Can anyone help me to provide code / script for Sold Out product page redirect for Envy 33.8.0 theme.

Once product is sold out it will be redirect to relevant collection page or homepage

and once back in stock redirection will be stopped.

Hi @LookandAdorn

Things such as these are best handled by Shopify partners as it needs to be looked at after logging into your individual store, so you can hire one, however, if you want the script and want to do it on your own, then you can add the below either in product.liquid or main-product.liquid depending on your theme structure

The script may require some polishing but as mentioned it can only be done by looking at your theme structure.

Hope this help, if you still need further help, you can DM us.

Hi @LookandAdorn ,

Could you please share your Store URL and password (if applicable) so that I can review it and provide you with the appropriate solution code?

Looking forward to your response.

Thanks!

attached product liquid file.

https://drive.google.com/file/d/1KByMwvbi1TNrcs8JzFYi3rrCbPpTo0gA/view?usp=drive_link

please check the same and help us to update script.

attached product liquid file.

https://drive.google.com/file/d/1KByMwvbi1TNrcs8JzFYi3rrCbPpTo0gA/view?usp=drive_link

please check the same and help us to update script