Auto Scroll Review Section (Empire Theme)

Solved

Auto Scroll Review Section (Empire Theme)

ChinChile
Tourist
7 0 1

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

Accepted Solution (1)
gr_trading
Shopify Partner
2045 149 206

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);
})
For any custom development WhatsApp or connect at Email ID: support@grtrading.in for quick consultation. | Shopify Free codes
To support Buy Me a Coffee

View solution in original post

Replies 4 (4)

gr_trading
Shopify Partner
2045 149 206

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...

For any custom development WhatsApp or connect at Email ID: support@grtrading.in for quick consultation. | Shopify Free codes
To support Buy Me a Coffee
ChinChile
Tourist
7 0 1

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.

gr_trading
Shopify Partner
2045 149 206

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);
})
For any custom development WhatsApp or connect at Email ID: support@grtrading.in for quick consultation. | Shopify Free codes
To support Buy Me a Coffee
ChinChile
Tourist
7 0 1

This fixed it. Thanks!