How to reformat product price in Squarespace

To display product prices without decimals and comma (e.g., change 15,000.00 to 15000 or 15,000), follow the steps below.

Step 1: Access Code Injection

Navigate to your site’s Admin Panel.

Go to Website Pages → Scroll down to Custom Code → Code Injection.

Step 2: Add the Code

Copy the entire code block below and paste it into the Header or Footer section of Code Injection.

Click Save and refresh the page.

<!-- Reformat Product Price (15,000.00 -> 15000 / 15,000) -->
<!-- Author: Dmytro Kyselov https://dmytrokyselov.com/ I❤️☕️ coff.ee/dmytrokyselov -->
<script src="https://cdn.jsdelivr.net/npm/@ryanmorr/ready@1.4.1/dist/umd/ready.min.js"></script>
<script>
const reformatPriceOptions = {
  displayComma: false // Set to true (displayComma: true) to display the comma in the price (e.g. 15,000)
};
(function(){ function reformatPrice(price){ const priceClone=price.cloneNode(true); priceClone.classList.add('product-price-clone'); price.parentNode.insertBefore(priceClone, price.nextElementSibling); price.style.display='none'; function reformat(){ priceClone.innerHTML=format(price.innerHTML);} function format(text){ let reformattedText=reformatPriceOptions.displayComma ? text: text.replace(',', ''); return reformattedText.replace(/\.\d{2}/, '');} function watch(){ const observer=new MutationObserver(reformat); observer.observe(price,{ childList: true});} reformat(); watch();} ready('.product-list-item-price:not(.product-price-clone),.product-price-value:not(.product-price-clone),.product-price:not(#main-product-price):not(.product-price-clone),.original-price:not(.product-price-clone)', reformatPrice)})();
</script>
<!-- end Reformat Product Price -->

Note:

  • This code removes comma and decimal points. If you only want to remove decimals but keep the comma (e.g., 15,000), replace this line displayComma: false with this displayComma: true

Omari Harebin

Omari Harebin is the founder of SQSPThemes.com — a curated hub of tools, templates, and mentorship for Squarespace designers and developers. With over a decade in the ecosystem and nearly $2M in digital product sales, he helps creatives turn client work into scalable assets and more freedom in their business.

https://www.sqspthemes.com
Previous
Previous

How to add a sold out waiting list to your product page