Reformat Product Price

reformatprice.png

Step One

From your Squarespace account, go to Code Injection: Settings > Advanced > Code Injection

Step Two

Copy and paste the code below into the Footer Code Injection box.

<!-- Reformat Product Price (15,000.00 -> 1500) --> 
<!-- Author: Dmitry Kiselyov @_dmitrykiselyov --> 
<script src="https://cdn.jsdelivr.net/gh/ryanmorr/ready@1.2/dist/ready.min.js"></script> 
<script> 
(function() { 
ready('.product-price:not(.product-price-clone)', reformatPrice); 
function reformatPrice(price) { 
var priceClone = price.cloneNode(true); 
priceClone.classList.add('product-price-clone'); 
price.parentNode.insertBefore(priceClone, price.nextElementSibling); 
price.style.display = 'none'; 
function reformat() { 
priceClone.innerHTML = price.innerHTML; 
var target = priceClone.children[0] || priceClone; 
target.textContent = target.textContent.replace(',', '').replace(/\.\d{2}/, ''); 
} 
function watch() { 
var observer = new MutationObserver(reformat); 
observer.observe(price, { childList: true }); 
} 
reformat(); 
watch(); 
} 
})(); 
</script> 
<!-- end Reformat Product Price -->

Step Three

You do not need to change any of the values or properties.

Save and refresh the page. 👍

Moov Labs