Shopify themes, liquid, logos, and UX
Looking for code that will allow my customers to select thumbnail and it change the variant.
Hello @Beepbeet ,
Since we not really know the exact context of your site, here is a general guide with example you can try to follow:
{% for image in product.images %}
<img src="{{ image.src }}" alt="{{ image.alt }}" class="product-thumbnail" data-variant-id="{{ image.id }}">
{% endfor %}
document.addEventListener("DOMContentLoaded", function() {
var thumbnails = document.querySelectorAll(".product-thumbnail");
thumbnails.forEach(function(thumbnail) {
thumbnail.addEventListener("click", function() {
var variantId = this.dataset.variantId;
var selectElement = document.querySelector("select[name='id']");
if (variantId && selectElement) {
selectElement.value = variantId;
}
});
});
});
This code listens for click events on each thumbnail image. When a thumbnail is clicked, it retrieves the corresponding variant ID from the data-variant-id attribute and sets the value of the variant select dropdown to that ID.
Hope this can help. Let us know if you need any further support.
Ali Reviews team.
I am not finding a product-template.liquid. Is this code good for the new 2.0 sites? I can't seem to find similar in Sections folder. Any help greatly appreciated!
I am also facing the same issue. Has your issue been resolved? If it has, then please tell me how.
Hello,
Could you please provide the specifics for making this change in the Prestige Theme? Thank you
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024