I have previously made a financing calculator, so you can see the price if you pay over 10 months. An update has arrived in Shopify, which blocks my scripts.
monthly payment <span class="grafikr-finans-price-10">{{ product.price | divided_by: 10 | money }}</span></p>
$('.grafikr-finans-price-10').text(((price.replace('.','')/10).toFixed(1) + '0 kr.').replace('.',','))
Anyone know how to fix the problem?
You can se the problem here:https://imgur.com/Y4k9amz
You can see the full script here:
<script>
$(document).ready(function() {
function setprice() {
var price = $('#price-field').text().replace(',00 DKK','')
for (i = 0; i < $('.grafikr-finans-price').length; i++) {
$('.grafikr-finans-price').text(price + ' kr.')
}
$('.grafikr-finans-price-10').text(((price.replace('.','')/10).toFixed(1) + '0 kr.').replace('.',','))
}
setprice()
$('.sod_option').click(function() {
setTimeout(function() {
setprice()
}, 500)
});
});
</script>
2
Answers
This work :-)
price.replace
is going to give you a string, which cannot be divided (henceNaN
).Try this: