MarikaS Posted November 19, 2019 Share Posted November 19, 2019 Hi there. I use the Adirondack template for my site and am wanting to remove the trailing decimal 00's from my pricing. For example I want $249.00 to display as $249. Any idea how to make this happen? Any help would be much appreciated, thanks! Link to comment
1 paul2009 Posted December 14, 2019 Share Posted December 14, 2019 (edited) The code was written in 2016 and like many of the older code samples provided on forums, it therefore understandably doesn’t take into account the introduction of Ajax on many Squarespace templates since that time. Turning off Ajax in Site Styles will fix this but it’s just a workaround. A better solution is to replace (function() { with window.Squarespace.onInitialize(Y, function() { If like me you’d like to understand why, I wrote an explanation here: https://sf.digital/squarespace-solutions/why-doesnt-my-code-work-until-i-refresh-the-page Edited December 14, 2019 by paul2009 brandon and dhob 2 About Paul: Circle Community Leader who values honesty, transparency, respect and appreciation ♥.Work: Squarespace Expert and founder of SF Digital, a company dedicated to improving Squarespace websites by building the features Squarespace didn't include™. See our range of extensions for Squarespace to improve your store.Content: Links in my posts may refer to SF Digital products or may be affiliate links. Link to comment
1 creedon Posted October 2, 2021 Share Posted October 2, 2021 @misimo Please see Store Product Price Remove Decimal for Prices Greater Than or Equal to N. Let us know how it goes. dhob 1 Find my contributions useful? Please like, upvote, mark my answer as best , and see my profile. Thanks for your support! Link to comment
0 paul2009 Posted November 19, 2019 Share Posted November 19, 2019 You can do it with the code that @brandon provided here: http://squarespace.cloud.answerhub.com/questions/152145/can-someone-help-me-change-coding-to-get-rid-of-de.html brandon and MarikaS 2 About Paul: Circle Community Leader who values honesty, transparency, respect and appreciation ♥.Work: Squarespace Expert and founder of SF Digital, a company dedicated to improving Squarespace websites by building the features Squarespace didn't include™. See our range of extensions for Squarespace to improve your store.Content: Links in my posts may refer to SF Digital products or may be affiliate links. Link to comment
0 MarikaS Posted November 19, 2019 Author Share Posted November 19, 2019 Thank you so much @paul2009 and @brandon. Worked a treat! paul2009 1 Link to comment
0 brandon Posted November 20, 2019 Share Posted November 20, 2019 Good find @paul2009. That's an example of code I don't even remember writing. One time I went looking for a coding solution I couldn't solve, and was happy when I found it on Answers. Then I realized it was my own answer... Magda555 and paul2009 1 1 If a response helped you out, send a 'Like' 👍 (bottom-right) and/or 'Upvote' (top-left) Link to comment
0 paul2009 Posted November 20, 2019 Share Posted November 20, 2019 Been there too @Brandon! The Community team have now imported the old Answers post 👍 About Paul: Circle Community Leader who values honesty, transparency, respect and appreciation ♥.Work: Squarespace Expert and founder of SF Digital, a company dedicated to improving Squarespace websites by building the features Squarespace didn't include™. See our range of extensions for Squarespace to improve your store.Content: Links in my posts may refer to SF Digital products or may be affiliate links. Link to comment
0 EllisCo Posted December 14, 2019 Share Posted December 14, 2019 (edited) Thanks @brandon and @paul2009 for this code! It works perfectly when I first save it in the foot code injection, but as soon as I refresh a page, it reverts to the normal pricing with decimals again. I wonder if it's because our prices are in £ rather than $. I've tried swapping the currencies out in the code but I really don't know what I'm doing! Any ideas how I could get it to work? Here's an example of what I'm working with: https://ellishampers.co.uk/hampers/magnificent-n8-the-marvel UPDATE: Just checked that the above linked worked and the decimals had disappeared! Tried in incognito and they came back again. It seems that if I refresh the page the code works, but the first time I load it the decimals are always there. In normal browsing (not incognito), the same applies but every time you load the page, you also see the decimals briefly before they disappear. Worth putting the code in the header for this or is that something that could go wrong? Thank you! 😊 Edited December 14, 2019 by EllisCo Link to comment
0 JiriWranovsky Posted January 2, 2020 Share Posted January 2, 2020 Hi, thank you very much for this solution, I've found this to work great for me as well apart from a single instance when I choose two variables of a product to add to cart - such as a size and a color. When two variables are chosen, suddenly the two decimals appear again. Any idea why that might be and if there's a way to solve this? Link to comment
0 jjjuliejj Posted May 1, 2020 Share Posted May 1, 2020 On 11/19/2019 at 9:06 AM, paul2009 said: You can do it with the code that @brandon provided here: http://squarespace.cloud.answerhub.com/questions/152145/can-someone-help-me-change-coding-to-get-rid-of-de.html This link is no longer active. Can you repost the code, and does it work for 7.1? Thank you! Ejderha 1 Link to comment
0 paul2009 Posted May 1, 2020 Share Posted May 1, 2020 About Paul: Circle Community Leader who values honesty, transparency, respect and appreciation ♥.Work: Squarespace Expert and founder of SF Digital, a company dedicated to improving Squarespace websites by building the features Squarespace didn't include™. See our range of extensions for Squarespace to improve your store.Content: Links in my posts may refer to SF Digital products or may be affiliate links. Link to comment
0 jjjuliejj Posted May 3, 2020 Share Posted May 3, 2020 Thank you. That code does not seem to work in 7.1. Ejderha 1 Link to comment
0 irenerodriguezca Posted April 21, 2021 Share Posted April 21, 2021 For 7.1 version I found https://www.ghostplugins.com/steps/reformat-product-price-71-version To me it worked perfectly! Link to comment
0 misimo Posted September 28, 2021 Share Posted September 28, 2021 Hi - I am wondering if it is possible to switch between variants? I want anything with trailing double decimals to display without them - for example $250.00 should display as $250. But I still want to keep my trailing decimals on my little numbers - for example I want $1.50 to display as that - not $1.5 Is that possible or an impossibility? I have used the footer injection here - can it be edited to support this? <script> window.Squarespace.onInitialize(Y, function() { var prices = document.getElementsByClassName('sqs-money-native'); var thisPrice; var i, I; for (i=0, I=prices.length; i<I; i++) { thisPrice = prices[i]; thisPrice.innerHTML = thisPrice.innerHTML.replace(/(\.[0-9]*?)0+$/, "$1").replace(/\.$/, ""); //http://stackoverflow.com/questions/1015402/1015434#1015434 } })(); Link to comment
0 creedon Posted September 28, 2021 Share Posted September 28, 2021 @misimo Please post the URL for a page on your site where we can see your issue. If your site is not public please set up a site-wide password, if you've not already done so. Post the password here. Adding a site-wide password is not a security breach. Please read the documentation at the link provided to understand how it works. Please read the documentation at the link provided on how to share a link to your site to understand how it works. A link to the backend of the your site won’t work for us, i.e. a url that contains /config/. We can then take a look at your issue. Find my contributions useful? Please like, upvote, mark my answer as best , and see my profile. Thanks for your support! Link to comment
0 saskia14 Posted January 21 Share Posted January 21 I'm also trying to remove decimals, I've tried a code that was linked here (see below) which has worked mostly, however it turns 11.90 into 11.9 and so on. I don't want to delete all the zeros. Can anyone help? <script> (function() { var prices = document.getElementsByClassName('sqs-money-native'); var thisPrice; var i, I; for (i=0, I=prices.length; i<I; i++) { thisPrice = prices[i]; thisPrice.innerHTML = thisPrice.innerHTML.replace(/(\.[0-9]*?)0+$/, "$1").replace(/\.$/, ""); //http://stackoverflow.com/questions/1015402/1015434#1015434 } })(); </script> Link to comment
0 creedon Posted January 21 Share Posted January 21 @saskia14 The code you have there won't work as it doesn't take into account some important changes to how SS now works. Please see the following. Let us know how it goes. Find my contributions useful? Please like, upvote, mark my answer as best , and see my profile. Thanks for your support! Link to comment
Question
MarikaS
Hi there. I use the Adirondack template for my site and am wanting to remove the trailing decimal 00's from my pricing.
For example I want $249.00 to display as $249.
Any idea how to make this happen? Any help would be much appreciated, thanks!
Link to comment
Top Posters For This Question
4
3
2
2
Popular Days
Nov 19
3
May 1
2
Jan 21
2
Nov 20
2
Top Posters For This Question
paul2009 4 posts
creedon 3 posts
jjjuliejj 2 posts
MarikaS 2 posts
Popular Days
Nov 19 2019
3 posts
May 1 2020
2 posts
Jan 21 2022
2 posts
Nov 20 2019
2 posts
Popular Posts
paul2009
You can do it with the code that @brandon provided here: http://squarespace.cloud.answerhub.com/questions/152145/can-someone-help-me-change-coding-to-get-rid-of-de.html
brandon
Good find @paul2009. That's an example of code I don't even remember writing. One time I went looking for a coding solution I couldn't solve, and was happy when I found it on Answers. Then I realized
paul2009
The code was written in 2016 and like many of the older code samples provided on forums, it therefore understandably doesn’t take into account the introduction of Ajax on many Squarespace templates si
16 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment