Skip to content

Commit

Permalink
Compatibility for WooCommerce Variation Swatches and Photo
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtisbradley committed Jul 1, 2020
1 parent ab4f7e9 commit 12b0106
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions wooswipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
});
}

// on variation change set popup index to changed variation
$(document).on("change", ".variations select", function() {
var imgsrc = $("#wooswipe a").attr("href");
var srcind = 0;
Expand All @@ -195,5 +196,20 @@
});
$("#wooswipe img").attr("data-ind", srcind);
});

// compatibility for "WooCommerce Variation Swatches and Photo". On swatch change set popup index to changed variation
if ($(".variations .swatch-control").length > 0) {
$(".variations_form").addClass('has-swatches');
$(".variations_form.has-swatches").on('change', function (e) {
var imgsrc = $("#wooswipe a").attr("href");
var srcind = 0;
$(".thumbnails .thumb").each(function () {
if (imgsrc == $(this).attr("data-hq")) {
srcind = $(this).parent().attr("data-slick-index");
}
});
$("#wooswipe img").attr("data-ind", srcind);
});
}
})();
})(document, window, jQuery);

0 comments on commit 12b0106

Please sign in to comment.