How do I replace product price ".00" with ",-"

How do I replace product price ".00" with ",-"

PetervdHoeven
Excursionist
21 1 2
 
Hello,
 
How do I make the price end with '',-'' instead of '',00''
 
For example: 39,- and not 39,00
 
Thanks in advance!
Replies 15 (15)

suyash1
Shopify Partner
9561 1195 1536

@PetervdHoeven - can you please check price format in your store settings? also may need to use price filter "money_without_trailing_zeros" in your theme code for price.

Support me | To build shopify pages use pagefly | You are welcome to contact me - suyash.patankar@gmail.com , My timezone is GMT+5:30.
PetervdHoeven
Excursionist
21 1 2

The price format only allows me to completely remove the last two decimals with “{{ amount_no_decimals }}” so it looks like “39”, is there a way to add “,-“ after the price? I currently use {{ amount }}. 

How should i use price filter "money_without_trailing_zeros" in my theme code? 

 

suyash1
Shopify Partner
9561 1195 1536

@PetervdHoeven - can you put like this in your price format and check ? {{ amount_no_decimals }},

 

so add "," after {{ amount_no_decimals }}

Support me | To build shopify pages use pagefly | You are welcome to contact me - suyash.patankar@gmail.com , My timezone is GMT+5:30.
PetervdHoeven
Excursionist
21 1 2

This works party, this removes the last two decimals for all prices, not only prices that end with ".00''. And some prices end with .50 for example so I cant remove the last two decimals for all prices. 

suyash1
Shopify Partner
9561 1195 1536

@PetervdHoeven - did you try these in this link?

 

https://help.shopify.com/en/manual/payments/currency-formatting

Support me | To build shopify pages use pagefly | You are welcome to contact me - suyash.patankar@gmail.com , My timezone is GMT+5:30.
Zworthkey
Shopify Partner
5581 642 1575

@PetervdHoeven 
hi,
you can try this :

{{ price | money }}

for the Decimal points in price.

PetervdHoeven
Excursionist
21 1 2

Hi,

where do I need to place “{{ price | money }}” ?

Zworthkey
Shopify Partner
5581 642 1575

@PetervdHoeven 

sorry, you want to add '-' instead of '.00'

PetervdHoeven
Excursionist
21 1 2

Yes, so the price looks like 39,- instead of 39.00 

Zworthkey
Shopify Partner
5581 642 1575

614bc3501c0df8a0df0fb518_shopify-change-currency-format-min.png

@PetervdHoeven 

1.Go to the Setting.

2.Navigate to the Store details

3.Then Store currency

4.Then click on Close formating

5.${{amount}} change this to ${{amount_no_decimals}}-

PetervdHoeven
Excursionist
21 1 2

Hi, this removes the decimals of all prices, not only the ones that end with “.00”. I have prices that don’t end with .00 that need to stay the same. For example “35,50”. 

jeroenhartman
Visitor
1 0 0

Still no answer on this question, I guess? I have the same request, so I hope you have found a solution after all. If so, can you share this with us please?

khalid1214
Shopify Partner
4 0 0

Hey @PetervdHoeven , @jeroenhartman you can use the "remove" filter inside your code where the price tag is used, like this:

{{ product.price | money_with_currency | replace: ",00", ",-" }}

Let me know if this helps, thank you!

Shopify Freelance Developer with 5 years of experience in Liquid, HTML/CSS, and JavaScript/JQuery and building Shopify stores.
https://www.upwork.com/freelancers/khalidbashir

Youriivdh
Shopify Partner
1 0 0

Hi @PetervdHoeven & @jeroenhartman ,

 

In the "dawn" theme, I modified the price.liquid to change this.

 

{{ money_price }} -> {{ money_price | replace: ',00', ',-'}}

&

{{ compare_at_price }} -> {{ compare_at_price | money | replace: ',00', ',-'}}

Also, you may have to change "money_with_currency" to this code.

Kind regards,

Youri van der Heijden
Webmaster & Digital Marketer

MuhammadAqib
Shopify Partner
14 1 1

Hey,
1. In your Shopify Admin go to online store > themes > actions > edit code and search theme.liquid file.
2. In your theme.liquid file, find the </body> (press CTRL + F  on Windows or command + F on Mac)
3. paste this code right above the </body> tag:

<script>
function updatePrice(){
var prices = document.querySelectorAll(`.price-item`);


if (!prices)return;

for (var each of prices){
each.innerText = each.innerText.replace('.00', '');
}
}

 window.onload = function() {
setTimeout(updatePrice, 50);
            }

</script>