🏷️ Display only full dollar value (no decimal or cents)
This is a Javascript code that can be used on any site with a Business or Commerce subscription plan.
This JavaScript code finds all product prices on the page and updates them to show only the whole dollar amount, removing the decimal and cents.
How to use this code
This code is designed to work on the product listing page of a Squarespace store and individual product pages. Add the following code to your site wide footer code injection. You’ll find this under Pages → Custom Code → Code Injection → Footer
<script>
document.addEventListener("DOMContentLoaded", function () {
// Combine selectors for both product list and product detail prices
const priceElements = document.querySelectorAll(
".product-list-item-price, .product-price-value"
);
priceElements.forEach(function (priceEl) {
const originalText = priceEl.textContent.trim();
// Match the dollar amount only (e.g., $25 from $25.00)
const match = originalText.match(/\$\d+/);
if (match) {
priceEl.textContent = match[0];
}
});
});
</script>