Jump to content

countdown script doesn't work if CAHCE is ON


HeyVoOn
 Share

Recommended Posts

Hello everyone,

 

I am running PS 1.6.0.14 with TitanShop and some custom modules. In this theme I use "cshotdeals" and "cscountdown".

 

cshotdeals shows a block on the left with deals and a countdown timer based on the time set for the product deal.

 

The problem is the the block only shows the countdown if the Prestashop CACHE is OFF. Otherwise the countdown doesn't show up.

 

post-944125-0-26054900-1430308788_thumb.png

 

Below please find the code for the countdown.tpl

{addJsDefL name=cd_day}{l s='days' mod='cscountdown'}{/addJsDefL}
{addJsDefL name=cd_hour}{l s='hours' mod='cscountdown'}{/addJsDefL}
{addJsDefL name=cd_min}{l s='mins' mod='cscountdown'}{/addJsDefL}
{addJsDefL name=cd_sec}{l s='secs' mod='cscountdown'}{/addJsDefL}
{if $timeRemaining !== null && $timeRemaining >= 0}
    <div id="countdown_{$id_product}" class="timer"></div>
    <script>
        (function() {
            var seconds = {$timeRemaining};
            function secondPassed(){
                var hour = 24;
                var minutes = 60;
                var day = Math.round((seconds - (86400 / 2)) / 86400);
                var remainingSeconds = seconds % 60;
                if (seconds === 0) {
                    clearInterval(countdownTimer);
                    $('#countdown_{$id_product}').html('0:00:00:00');
                }
                else{
					var cd_html = '';
					
                    if ((seconds % 86400) !== 0) {
                        hour = Math.round(((seconds % 86400) - 1800) / 3600);
                    } 
                    if ((seconds % 3600) !== 0) {
                        minutes = Math.round(((seconds % 3600) - 30) / 60);
                    }
					cd_html +='<ul class="clock">';
					if(day > 0)
					{
						cd_html += '<li><span class="days">'+day+'</span>';
						cd_html += '<p class="timeRefDays">'+cd_day+'</p></li>';
					}
					cd_html += '<li><ul class="clock-sub">';
						
						cd_html += '<li><span class="hour">'+hour+'</span>';
						cd_html += '<p class="timeRefhour">'+cd_hour+'</p></li>';
						
						cd_html +='<li><span class="minutes">'+minutes+'</span>';
						cd_html += '<p class="timeRefminutes">'+cd_min+'</p></li>';
						
						cd_html += '<li><span class="remainingSeconds">'+remainingSeconds+'</span>';
						cd_html += '<p class="timeRefseconds">'+cd_sec+'</p></li>';
							
					cd_html += '</ul></li>';
					cd_html += '</ul>';
                    $('#countdown_{$id_product}').html(cd_html); 
                    seconds--;
                }
            }

             var countdownTimer = setInterval(function(){
                secondPassed();
            }, 1000);
           
        })(jQuery);

    </script>
{/if}

Could anyone please help me figure out why this ishappening when PS CACHE is On? 

 

Thank you in advance for any clue. This is driving me nuts!

 

 

 

Edited by HeyVoOn (see edit history)

Share this post


Link to post
Share on other sites

Maybe the old tpl is still in cache available, therefore not adding the timer code?

 

Clear all cache, turn OFF caching in advanced parameters->Performance (here you can also clear cache (top right of page)

turn ON force compile here as well

 

When it now works, turn caching on again and see if this helped.

(Then turn off force compile)

 

 

My 2 cents,

pascal.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More