Shopify themes, liquid, logos, and UX
Hi there! I'm using the Debut theme and would like to remove the trailing zeros from my whole number product prices in the storefront. Here's an example of another brand doing it successfully in their product recommendation section.
Can anyone advise how to tackle this?
Solved! Go to the solution
This is an accepted solution.
Hey,
1. In your Shopify Admin go to online store > themes > actions > edit code
2. In your theme.liquid file, find the </body> (press CTRL + F 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>
Ideally you'd want to get a developer to code it in a cleaner way into your theme via Liquid, but this will do the trick.
Please let me know whether it works.
Kind regards,
Diego
Hello,
Thank you for your question.
Please share your store URL, page URL and also password (if your store has one), I'll help you out to the best of my ability.
Kind regards,
Diego
This is an accepted solution.
Hey,
1. In your Shopify Admin go to online store > themes > actions > edit code
2. In your theme.liquid file, find the </body> (press CTRL + F 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>
Ideally you'd want to get a developer to code it in a cleaner way into your theme via Liquid, but this will do the trick.
Please let me know whether it works.
Kind regards,
Diego
Diego, thank you so much. It worked beautifully!
@scedelstein hey, glad to hear. You're welcome!
Next time you need something feel free to contact me personally via e-mail, I'll be happy to help.
Kind regards,
Diego
Hey Diego,
i wanted to add that when i choose another size for example from my website, the extra two zeros are added again at the end of the price.
is there a way to avoid that ?
Hi Diego,
Thanks for the solution! But on the theme Optimal I don't see the codes over there. Can you maybe help me where to find the and copy paste this code?
Cheers! 🙂
Hi Diego
Ive tried the above step but didn't work for my store, I am working with minimal theme and below is my code, please let me know if its adjustable to remove those two extra zeros from the prices.. thanks a lot in advance.
My god man, you're a freaking life saver !
As 2024 wraps up, the dropshipping landscape is already shifting towards 2025's trends....
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024In today’s interview, we sat down with @BSS-Commerce to discuss practical strategies f...
By JasonH Nov 13, 2024