Narrative theme- Counter / html in Announcement bar

StudioM
Explorer
67 0 29

Hi Everyone!

 

I'm would like to use html in the announcement bar.

In particular, a code for this countdown timer:

 

var countDownDate = new Date("apr 1, 2021 00:00:00 UTC+1").getTime();

var x = setInterval(function() {

var now = new Date().getTime();

var distance = countDownDate - now;

var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);

document.getElementById("demo").innerHTML = days + " Days │" + hours + " Hours │"
+ minutes + " Minutes │" + seconds + " Seconds ";

if (distance < 0) {
clearInterval(x);
document.getElementById("demo").innerHTML = "EXPIRED";
}
}, 1000);

 

Many thanks in advance!

0 Likes
suyash1
Shopify Partner
2561 273 429

@StudioM - this custom html may not work from announcement bar field in customizer, hence we may need to put it in the theme code to check

You are welcome to contact me, my email - suyash.patankar@gmail.com
Free Shopify solutions/tutorials on youtube
#1 page builder app on Shopify - for FREE! PageFly
0 Likes
StudioM
Explorer
67 0 29

Hi @suyash1 ,

Thanks for your reply.

I know it requires doing something in the backend.

I'm hoping that someone here can tell me what exactly I need to do / where to copy the code to in order to make it work.

0 Likes
suyash1
Shopify Partner
2561 273 429

@StudioM _ your code looks like js code, I think it will be visible in the place where it is added, if that is the case then will need to add it into announcement bar code in the backend, if you can add me to staff then I can check it and let you know.

You are welcome to contact me, my email - suyash.patankar@gmail.com
Free Shopify solutions/tutorials on youtube
#1 page builder app on Shopify - for FREE! PageFly
0 Likes