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. He helps Squarespace designers and product sellers find the market moment inside their existing work, then turn it into articles, offers, demos, and assets that compound.

Start here: Book a free clarity call to get a read on what you already have →

https://www.omariharebin.com
Previous
Previous

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