Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Can someone help me change coding to get rid of decimal places in my pricing?


bahamascollective
Go to solution Solved by brandon,

Question

  • Answers 27
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

Popular Posts

Design > Site Styles > Disable Ajax Loading

Hi. The following Javascript, inserted via footer code injection should do the trick: <script> (function() { var prices = document.getElementsByClassName('sqs-money-native'); var

Simply delete this from the code: .replace(",","") (see highlighted section below)  

Posted Images

Recommended Posts

  • 1

Hi. The following Javascript, inserted via footer code injection should do the trick:


<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>

I didn't test this throughout your site...just checked a couple pages. Do let me know if this works for you.

-Brandon


If this or any other answer helps you out, please give credit where credit is due: Accept the answer if you're the poster or Up-Vote the answer if you're not the poster. If it didn't help, feel free to inquire further or wait and see what others have to say. Code is provided without any warranty, expressed or implied.

If a response helped you out, send a 'Like' 👍 (bottom-right) and/or 'Upvote' vote.jpg.c260784ece77aec852b0e3049c77a607.jpg (top-left)

Link to post
  • 0

Hi .While not necessary, a link to a page on your site that shows the elements you'd like changed may help others offer help.

If a response helped you out, send a 'Like' 👍 (bottom-right) and/or 'Upvote' vote.jpg.c260784ece77aec852b0e3049c77a607.jpg (top-left)

Link to post
  • 0
On 1/28/2021 at 7:15 AM, Evelina said:

It s for all the products in this shop https://www.moderncharcuterie.co/shop-charcuterie-boards

Thank you!

Add to Code InjectionFooter

<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 post
  • 0
8 hours ago, tuanphan said:

Yes. Quick view needs a different code.

 

Any idea what that code is?  Any way to make it more site-wide as surely it is as universal as say the currency symbol?!  So anywhere their is a price show XXXXX

Link to post
  • 0
16 hours ago, MarikaS said:

@brandon I've also realised that I have to reload my product pages for the .00s to disappear - any idea why that would happen?

Design > Site Styles > Disable Ajax Loading

Link to post
  • 0
On 9/1/2016 at 2:59 AM, brandon said:

Hi. The following Javascript, inserted via footer code injection should do the trick:


 

<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>
 

I


If this or any other answer helps you out, please give credit where credit is due: Accept the answer if you're the poster or Up-Vote the answer if you're not the poster. If it didn't help, feel free to inquire further or wait and see what others have to say. Code is provided without any warranty, expressed or implied.
 

The code works great until you have to select a variant. Would anybody be able to help in making decimals stay once you select a variant?

Website for the reference: https://rocksforlife.com/our-jewellery/no-1-solitaire-ring-white-gold

All insights are very much appreciated! Maybe @brandon?

Link to post
  • 0
On 2/2/2021 at 3:46 PM, tuanphan said:

Add to Code InjectionFooter


<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>

 

The code works great until you have to select a variant. Would anybody be able to help in making decimals stay once you select a variant?

Website for the reference: https://rocksforlife.com/our-jewellery/no-1-solitaire-ring-white-gold

All insights are very much appreciated!

Link to post
  • 0

sf-digital-signature-logo-email145.png.46606a2288a2847f44d81b9b7b58f3a5.png
Hi, I'm Paul, founder of SF Digitalbuilding the features that Squarespace didn't include. Pick dates in any format, show prices in other currencies, take orders without payment or improve your cartI value honesty, integrity, transparency and respect. Links in my posts may refer to SF Digital products or may be affiliate links.  Squarespace. I've been a loyal supporter of the platform since 2007. 

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...