Advertisement
Guest User

Untitled

a guest
Dec 6th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. $(document).ready(function() {
  2. thumbnails = $('img[src*="/products/"]');
  3. if (thumbnails.length > 1) {
  4. thumbnails.bind('click', function() {
  5. var arrImage = $(this).attr('src').split('?')[0].split('.');
  6. var strExtention = arrImage.pop();
  7. var strRemaining = arrImage.pop().replace(/_[a-zA-Z0-9@]+$/,'');
  8. var strNewImage = arrImage.join('.')+"."+strRemaining+"."+strExtention;
  9. if (typeof variantImages[strNewImage] !== 'undefined') {
  10. productOptions.forEach(function (value, i) {
  11. optionValue = variantImages[strNewImage]['option-'+i];
  12. if (optionValue !== null && $('.single-option-selector:eq('+i+') option').filter(function() { return $(this).text().trim() === optionValue }).length) {
  13. $('.single-option-selector:eq('+i+')').val(optionValue).trigger('change');
  14. }
  15. });
  16. }
  17. });
  18. }
  19. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement