I have written a external JS script that shows a custom text on the stores product's page. Currently the JS function is called once, on the window.onload function.
I want my script to be able to detect a variant change and swap out the text to a different one, whenever a different variant is selected. How do I detect a variant change and get it's price in an external JS file, using only JS/jQuery function.
My code in shopify store: <script id="testscript" src="https://example.com/test.js?amount=${{ product.price | divided_by: 100.00 | round: 2 }}"></script> <div id="mydiv"></div> My code in test.js: window.onload = function () { document.getElementById("mydiv").innerHTML += ("<p>This is a test.</p>"); };
User | Count |
---|---|
16 | |
16 | |
13 | |
12 | |
11 |