Hi again,
We had someone write some Javascript using your advice above and the button is indeed getting loaded automatically now but it isn't loading the widget from ChannelSight.
These are loaded into the Header via Code Injection
<!--load channelsight loader-->
<script src="https://cdn.channelsight.com/widget/scripts/cswidget.loader.js" defer></script>
<!--load jquery-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
Here is the Javascript written on the Store's Header via Advance/Page Header Code Injection:
<script>
jQuery(document).ready(function (){
var pathname = window.location.pathname;
jQuery.ajax({
url: pathname + "?format=json-pretty",
dataType: "json",
success: function (data) {
sku = data.item.structuredContent.variants[0].sku;
console.log(sku);
}
});
setTimeout(function(){
jQuery('.ProductItem-details-excerpt').append('<p><button class="cswidget sqs-block-button-element--small sqs-button-element--tertiary sqs-block-button-element cs-unloaded cswidget-root _xmynltb3v" data-asset-id="2088" data-product-sku="'+sku+'" type="button" data-instanceid="_xmynltb3v">Buy Now</button></p>')
}, 1000);
})
</script>
If you look at our test page: https://esatto.house/test/p/7kg-heat-pump-dryer, the top Buy Now button is the one I've placed by adding the code via a .csv file which correctly loads the ChannelSight widget.
The below Buy Now button is the one loaded by Javascript referencing the SKU of the product but it doesn't load the ChannelSight widget. Is there something I can do for the button to load the ChannelSight widget via Javascript?
Thanks in advance.