Truncate prices with XX,00 to XX

Hello guys,

hope you can help with this issue: I want to insert a script into an online shop that truncates all prices on the page from e.g. 249,00 € to 249 €. So I want to erase “,00” if that is true. Other prices like 249,99 € shoulden’t be touched.

Thank you very much.

.replace(",00 €"," €")

Thanks for your post.

To be ownest I am javascript newb and it didn’t run. I used that line in the header:

object.onload = function(){.replace(",00 €"," €")};

Any idea whats wrong?

To be honest,

do you think it is a good idea to change an online shop application without any knowledge?

If you want to have a quick fix, hire someone who has the knowledge and pay him.
If you have time, start learning javascript with a tutorial, then a small project, a bigger project and in 1-2 years you can work on something like an online store.

What you are trying to do is like if a car mechanic tries to transplant a human heart.



Yeah… the advice you’re going to be able to get is going to be vague at best, because I dont think you’ve got the knowledge to know what you need to know?

Basically, you would need to understand the structure of the object you’re trying to manipulate, and then modify it accordingly.

I can’t give you a “put this here”, because I don’t know what you’re trying to modify, and how it needs to be modified to do it.

.replace works on a string object.

let myvar = "This is a cookie";
console.log(myvar.replace("cookie","string")); //outputs "This is a string" to the console.

Thank you, it’s a good time to learn JavaScript now.