{
$nextTick(async () => {
if (event.detail.option1) {
option1 = event.detail.option1;
}
if (event.detail.option2) {
option2 = event.detail.option2;
}
if (event.detail.option3) {
option3 = event.detail.option3;
}
if (event.detail.option4) {
option4 = event.detail.option4;
}
variant = findBestVariantMatch(variants, [option1,option2,option3,option4])
if (variant.featured_image?.src) {
image = variant.featured_image?.src;
variantImage = variant.featured_image?.src;
}
const resp = await fetch(window.location.pathname + '?variant=' + variant.id)
const html = await resp.text();
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
doc.querySelector('#reviewStarsLoader').remove();
doc.querySelector('#reviewStars').innerHTML = $refs.productContainer.querySelector('#reviewStars').innerHTML
$refs.productImage.setAttribute('x-on:click', doc.querySelector('#productImage').getAttribute('x-on:click'));
$refs.productHeader.innerHTML = doc.querySelector('#productHeader').innerHTML;
$refs.productOptions.innerHTML = doc.querySelector('#productOptions').innerHTML;
$refs.productInfoAndActions.innerHTML = doc.querySelector('#productInfoAndActions').innerHTML;
history.replaceState(null, null, '?variant=' + variant.id);
});
};
"
>