I have recently started using MyShop for my online store at www.myshop.com. The programming language they use is quite different from what I am used to.
For example, the total price in the basket.html script is displayed using the following code:
<span style="myshop-value:price-total-formatted;white-space:nowrap;"></span>
This span tag displays the total price of products in the basket without any data inside it. It seems to be linked to a CSS stylesheet, which is a new concept for me.
Now, I am trying to create a JavaScript function that displays a message based on the price. If the total price is less than €25, it should show "You'll have free shipping", and if it's over €25, it should display "You'll have to pay for shipping".
Here is the JavaScript code for this function:
<div id="price"></div>
<p id="shipping"></p>
<script>
var price = document.getElementById("price").innerHTML;
if (price < 24.99) {
document.getElementById("shipping").innerHTML = "You'll have free shipping";
}
if (price > 25) {
document.getElementById("shipping").innerHTML = "You'll have to pay for shipping";
}
</script>
However, I am facing an issue where the JavaScript function does not work correctly when I include the span tag with the style attribute inside the price div. It seems like the div cannot access the data. This type of programming is new to me, and despite my efforts to find a solution online, I have not been successful. Any help or explanation would be appreciated.