Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello,
I am trying to figure out a way to make the review section on my homepage auto rotate, but there isn't an option for this in the theme settings. I'm wondering how I can do this in the theme code. Thanks in advance!
Website: https://chinchileproducts.com
Thanks,
Tony
Solved! Go to the solution
This is an accepted solution.
Hi @ChinChile ,
Please find the updated script
document.addEventListener("DOMContentLoaded", function(event) {
var direction = 0;
setInterval(function(){
console.log(direction,"direction");
if(direction == 0){
var _next = document.querySelector(".testimonials .flickity-button.next").hasAttribute("disabled");
console.log(1,"next",_next);
if(_next === false){
document.querySelector(".testimonials .flickity-button.next").click()
}else{
direction = 1
}
}
if(direction == 1){
console.log(2,"next");
var _next = document.querySelector(".testimonials .flickity-button.previous").hasAttribute("disabled");
if(_next === false){
document.querySelector(".testimonials .flickity-button.previous").click()
}else{
direction = 0
}
}
},5000);
})
Hi @ChinChile,
Please paste below script code in your
online store -> edit code -> assest - > empire.js
Put below code at very end of the JS file
document.addEventListener("DOMContentLoaded", function(event) {
var direction = 0;
setInterval(function(){
console.log(direction,"direction");
if(direction == 0){
var _next = document.querySelector(".flickity-button.next").hasAttribute("disabled");
console.log(1,"next",_next);
if(_next === false){
document.querySelector(".flickity-button.next").click()
}else{
direction = 1
}
}
if(direction == 1){
console.log(2,"next");
var _next = document.querySelector(".flickity-button.previous").hasAttribute("disabled");
if(_next === false){
document.querySelector(".flickity-button.previous").click()
}else{
direction = 0
}
}
},5000)
});
Hope it will help...
Hi @gr_trading,
Thank you for the reply. I added the code and it was working on desktop, but on mobile it was affecting the featured collection instead of the testimonial section.
This is an accepted solution.
Hi @ChinChile ,
Please find the updated script
document.addEventListener("DOMContentLoaded", function(event) {
var direction = 0;
setInterval(function(){
console.log(direction,"direction");
if(direction == 0){
var _next = document.querySelector(".testimonials .flickity-button.next").hasAttribute("disabled");
console.log(1,"next",_next);
if(_next === false){
document.querySelector(".testimonials .flickity-button.next").click()
}else{
direction = 1
}
}
if(direction == 1){
console.log(2,"next");
var _next = document.querySelector(".testimonials .flickity-button.previous").hasAttribute("disabled");
if(_next === false){
document.querySelector(".testimonials .flickity-button.previous").click()
}else{
direction = 0
}
}
},5000);
})
This fixed it. Thanks!
Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025