Last active
February 4, 2022 23:55
-
-
Save vorvulev/54af71671b192e746e2831acc02017d9 to your computer and use it in GitHub Desktop.
Triggers the variant in product card
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EventBus.subscribe('products-ready:insales:common', function(data) { | |
$("[data-founded]").each(function(index, el) { | |
var pid = parseInt($(el).attr("data-product-id")), | |
vid = parseInt($(el).attr("data-founded")); | |
$(el).removeAttr('data-founded'); | |
Products._products[pid]._instance[0].variants.setVariant(vid); | |
}); | |
}); | |
EventBus.subscribe('change_variant:insales:product', function(data) { | |
data.action.product.find('a[href]').each(function(index, el) { | |
$(el).attr('href', $(el).attr('href').split('?variant_id')[0]+"?variant_id="+data.id+""); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Products._products[product_id]._instance[0].variants.setVariant(variant_id); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment