Jump to content

countdown script doesn't work if CAHCE is ON


Recommended Posts

Hello everyone,


I am running PS 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.




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>
        (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) {
					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>';

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


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)
Link to comment
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,


Link to comment
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
  • Create New...