Re: auto refresh

How can I make my product page auto-refresh only when a variant is clicked?

medelb7
New Member
6 0 0
hello,
i need someone to help me for my page product  do autorefresh when i click & change in a variant but not in any 5sec do auto refresh, please this is the code for autorefresh in 5sec, you can upgrate it.
i put this is code in product.liquid

<html>

   <head>

     

      <script type = "text/JavaScript">

         <!--

            function AutoRefresh( t ) {

               setTimeout("location.reload(true);", t);

            }

         //-->

      </script>

     

   </head>

  

   <body onload = "Javascript&colon;AutoRefresh(5000);">

      <p>This page will refresh every 5 seconds.</p>

   </body>

  

</html>

Replies 8 (8)

ThomasBorowski
Shopify Partner
803 71 242

What's the purpose of doing an auto-reload of the page when another variant is selected?

 

Also, this forum is for questions related to Shopify Scripts (part of Shopify Plus). You might get better responses if you post it in Shopify Design.

★ Smart Upgrades, Tips and Tutorials for Shopify themes: cartpunk.com
Did my solution work? Help other Community members easily find the correct solution and apply it to their own stores by marking it as the Accepted Solution and giving it a Thumbs Up
medelb7
New Member
6 0 0

my purpose for that, because Compare at price ( old price ) does not change when changing variant, it's change until i refresh the page

ThomasBorowski
Shopify Partner
803 71 242

A theme should implement in-place updates of price, images, etc. when the variant changes, see the docs here: https://shopify.dev/themes/product-merchandising/variants#variant-selection

★ Smart Upgrades, Tips and Tutorials for Shopify themes: cartpunk.com
Did my solution work? Help other Community members easily find the correct solution and apply it to their own stores by marking it as the Accepted Solution and giving it a Thumbs Up
medelb7
New Member
6 0 0

not solved my problem yet 😞

ThomasBorowski
Shopify Partner
803 71 242

What theme are you using?

★ Smart Upgrades, Tips and Tutorials for Shopify themes: cartpunk.com
Did my solution work? Help other Community members easily find the correct solution and apply it to their own stores by marking it as the Accepted Solution and giving it a Thumbs Up
medelb7
New Member
6 0 0
Click to expand...
im not using theme shopify, im using theme of themeforest ( envanto  )




ThomasBorowski
Shopify Partner
803 71 242

Yeah, thought as much. ThemeForest themes are often crap. If it's not implementing the methods to update product info on variant change there's probably more that's iffy about the theme. I would seriously recommend ditching it and going with one from the Theme Store or, if you're strapped for cash, go with Dawn or one of the legacy free themes like Debut, Brooklyn, etc.

★ Smart Upgrades, Tips and Tutorials for Shopify themes: cartpunk.com
Did my solution work? Help other Community members easily find the correct solution and apply it to their own stores by marking it as the Accepted Solution and giving it a Thumbs Up
medelb7
New Member
6 0 0

thanks for your advice !

can you to help me for upgrade this code for be do refresh when i shose a variant automaticlly
i put this is code in product.liquid

<html>

   <head>

     

      <script type = "text/JavaScript">

         <!--

            function AutoRefresh( t ) {

               setTimeout("location.reload(true);", t);

            }

         //-->

      </script>

     

   </head>

  

   <body onload = "Javascript&colon;AutoRefresh(5000);">

      <p>This page will refresh every 5 seconds.</p>

   </body>

  

</html>