I’m building my own theme using Timber as the basis, and have set up slick slider for product pages. I want to set it up so that choosing a variant will automatically advance the slider to the associated variant image, but I’m not quite sure how to set that up.
This is how I have my slider set up (the first slider shows the current slide, while the second slider acts as thumbnail navigation for the first one):
Yes, I did! After hunting around online and experimenting I figured it out.
First, I set up the product so that I uploaded all the images, and then when I created variants, I chose each variant image from the images I had already uploaded. That tied them to those specific images.
Then I just had to set up my script so that I’d use the position of that variant featured image to control what is shown in the main slider.
To do that, I added the following Javascript to the end of my product.liquid file:
if (variant.featured_image) {
var variantImagePos = variant.featured_image.position - 1;
$('.slider').slick('slickGoTo', variantImagePos);
}
I have actually found that previewing the XHR requests for products added to carts is awesome since it lets me see all the available JSON for products. I should have already been doing that, but had just been relying on Shopify docs previously. Seeing all the JSON has made it a lot easier to pinpoint values I need to manipulate in the DOM!
On the product page, I would like to know how to arrange arrows , thus so,“<” Main Image “>” , on each side of the product image, and have the arrows slide through the thumbnail images that are usually displayed below the main image. I certainly appreciate anyone’s feedback!
The ‘arrows: true’ property is the one that enables arrows. If you want to customize the arrows, you can use additional object properties like the following:
You’re essentially pointing each arrow to a node in the document. So you’ll want to be sure that you’re either just modifying the default buttons (as shown in the example), or creating new buttons in your markup and then pointing prevArrow and nextArrow to those.
Hey man, it’s great that you figured the solution: I am trying to implement the same thing however I might be missing something even after following your steps. Your store is password protected, any chance I can see all of this is in live action ?