Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Countdown Timer Rate Topic   - - - - -

 
  • Ghiyas
  • Senior Member
  • Trial users
  • Join Date: 07-Aug 17
  • 197 posts

Posted 12 April 2021 - 02:07 PM #1

Hello,

 

I've tried searching but cannot find any post or addon to help with this query.

 

I want to create a simple countdown timer on my website. The countdown should be for 4PM (Monday to Friday), as this is when our delivery cut off point is. After 4PM, the countdown should start again until the next day. On Saturday and Sunday, it should count down until 4PM on Monday.

 

 

I've seen this guide: https://www.w3school..._countdown.asp 

 

But with this, once it has counted down it doesn't reset again.


Not sure why the link isn't working, but here it is again: https://bit.ly/3g1onfh



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12044 posts

Posted 13 April 2021 - 10:36 PM #2

Easiest is to just point you to a reference: https://www.w3school...s_countdown.asp
You'll need to create a block where you want the timer with html similar to:

<div id="my_timer">
</div>

and you would (using the javascript from the link) do:

 document.getElementById("demo").innerHTML = days + "d " + hours + "h "

Using jQuerey is probably easier and cleaner....


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Ghiyas
  • Senior Member
  • Trial users
  • Join Date: 07-Aug 17
  • 197 posts

Posted 21 April 2021 - 08:57 AM #3

I did already look at that guide, but I can't seem to work out where I would put the javascript or JQuery in CS-Cart



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21796 posts

Posted 21 April 2021 - 01:21 PM #4

Try to wrap javascript (jquery) code with the following

{literal}
... your code here....
{/literal}

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12044 posts

Posted 21 April 2021 - 05:19 PM #5

I did already look at that guide, but I can't seem to work out where I would put the javascript or JQuery in CS-Cart

 
You can put it in a scripts.post.tpl in my_changes.  The path would be
    design/themes/responsive/templates/addons/hooks/index/scripts.post.tpl
And the content would be something like:
 
<script>
  // your JS goes here
<script>
 
Note Ecom's comments about using the literal tags.  If an opening and closing squirley-braces are on the same line you should use literal tags.  I.e.
 
myObj = {literal}{};{/literal}
// whereas this is okay
myObj = {
  "property" : "value"
}
Note also that you can use template variable in JS by doing:
myVar = "{$tplData}";
// or
myVar = "{$product.amount}";
Good luck.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.