Title: Decimals
Last modified: May 28, 2024

---

# Decimals

 *  [Rune Rasmussen](https://wordpress.org/support/users/syntaxerrorno/)
 * (@syntaxerrorno)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/decimals-12/)
 * I noticed your wrote in a post here recently ([https://wordpress.org/support/topic/betala-i-butik/#post-17695724](https://wordpress.org/support/topic/betala-i-butik/#post-17695724)),
   that your plugin requires tax, but that isn’t noted anywhere else, nor do you
   have any check or notification for it in the plugin. As a minimum such requirements
   should be mentioned in the installation instruction, and/or the FAQ, on the plugin
   page.
 * That said I also discovered you have a old article about it hidden in your Freshdesk
   portal:
 * > Använd inte färre än 2 decimaler i butiken
   > Ändrad den: Fre, 1 dec., 2017 vid
   > 10:11 F.M.
   > I WooCommerce så finns det en inställning för hur många decimaler man vill 
   > använda sig av i sin butik. Detta kan uppfattas som att det endast ändrar hur
   > decimalerna visas, men det har en större betydelse för funktionaliteten i butiken.
   > Exempel på hur det kan skapa problem
   > Om vi har en produkt som kostar 47 kr inklusive 25% moms. När vi plockar bort
   > momsen som är 9,40 kr så är produktens nettopris 37,60 kr.
   > Om antal decimaler är inställt på 0 så kommer WooCommerce att avrunda produktens
   > nettopris till 38 kr. Detta gör att när momssatsen räknas ut i betalmodulen
   > så blir det 47 kr / 38 kr = 1,2368 vilket blir ungefär 24% moms.
   > Eftersom den momssatsen inte finns kommer det att bli problem då Svea inte 
   > godtar andra momssatser än de som finns i landet, dessutom blir det fel momssats
   > eftersom det egentligen ska vara 25%.
   > Eftersom uträkningarna ovan endast innehåller siffror med en decimal så kommer
   > de att fungera om man antal decimaler inställt på 1 i WooCommerce, men om det
   > är så att man har produkters som har decimaler i priset inklusive moms kan 
   > man få problem om deras nettopris avrundas.
   > Därför kräver vår Svea Checkout-modul att man kör 2 decimaler i sin butik för
   > att modulen ska fungera som den ska.
   > Om du vill gömma decimaler kan du använda följande kod
   > Eftersom syftet med att ställa ner decimaler till 0 i butiken oftast är att
   > gömma nollor från priser (exempelvis visa 28,00 kr som 28 kr) har vi därför
   > här tagit med en lösning för att ta bort nollor från priser.
   > Denna lösning gäller om priset är ett heltal, om det finns decimaler så visas
   > dessa.
   > /**
   >  - Trim zeros in prices
   >    */add_filter( ‘woocommerce_price_trim_zeros’, ‘__return_true’);
 * But as we know, displaying decimals in a store is highly unusual for NOK, SEK
   and DKK – among other currencies. And that filter mentioned only helps if the
   store owner adds prices including tax, which also isn’t common, or in other ways
   ensures they ends up with just zeros in the decimals. But then again, adding 
   a campaign with percent discount will mess that up anyway.
 * Thus it surprises me that this isn’t handled better with calculation functions
   in the payment plugins, and/or by pulling out more of the info being available
   from WooCommerce, like the tax classes used and their values per order item –
   t.ex. to “recreate” Woos handling of tax and rounding.
 * It has to be possible to handle currencies, decimals and taxes better than this?!

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [The Generation](https://wordpress.org/support/users/thegeneration/)
 * (@thegeneration)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/decimals-12/#post-17788240)
 * Hi,
 * Using 2 decimals is standard practice when handling money since it’s the smallest
   amount that you can pay with. You could for example pay 1.23 NOK but you can’t
   pay 3.456 NOK.
 * In our previous answer that you’re referring to we didn’t say that tax had to
   be used but rather that in order for tax calculations to be correct there is 
   a need for two decimals. If you’re selling items without tax that’s no problem.
 * The reason it’s important that the calculations are precise is because of tax
   regulation laws stating that the tax on an item can only be 0/6/12/25 percent
   in Sweden and 0/8/10/11.11/15/24/25 percent for Norway. If the rounding of an
   item would result in the tax being something other like for example 10.2% that
   would result in Svea not accepting the order row.
 * If however you’re only selling items without tax (which is very unusual) you 
   could in theory use 0 decimals and it would work, although it could be faulty
   rounded if applying percentage discounts but WooCommerce and Svea would still
   accept them.
 * Best regards
 *  Thread Starter [Rune Rasmussen](https://wordpress.org/support/users/syntaxerrorno/)
 * (@syntaxerrorno)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/decimals-12/#post-17788248)
 * > Using 2 decimals is standard practice when handling money since it’s the smallest
   > amount that you can pay with. You could for example pay 1.23 NOK but you can’t
   > pay 3.456 NOK.
 * Sure, but it’s not standard in shops in the Nordic countries etc. I think you’re
   being well aware of that. 😉
   Most displays and handles prices like 2200,-T.ex.
   like the “small” shop [https://www.elgiganten.se](https://www.elgiganten.se)
 * > In our previous answer that you’re referring to we didn’t say that tax had 
   > to be used but rather that in order for tax calculations to be correct there
   > is a need for two decimals.
 * Sorry, that clearly was a typo, which the overall post should tell.
 * Anyhow let’s get back to the real issue, which is that most web shops don’t want
   to display decimals, and that this should and could be handled better for those
   shops. 🙂
   Or would you claim it’s impossible to get the tax class/value/rate 
   directly, together with the prices excluding tax? Or in any other way calculating
   it correctly?
 * _*AND not to forget, the issue regarding your missing documentations. _
    -  This reply was modified 1 year, 11 months ago by [Rune Rasmussen](https://wordpress.org/support/users/syntaxerrorno/).
 *  Plugin Author [The Generation](https://wordpress.org/support/users/thegeneration/)
 * (@thegeneration)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/decimals-12/#post-17789425)
 * Hi,
 * If you want to display your prices such as “2200 kr” then you can use the snippet
   provided earlier:
 * `add_filter( 'woocommerce_price_trim_zeros', '__return_true' );`
 * However if a discount results in there being minor currency (öre/øre) to the 
   price that would be displayed as “1700.50 kr”
 * We could theoretically look at the tax classes being used, however that would
   instead risk the rounding to create a difference in price between what’s being
   shown in WooCommerce and what’s being charged by Svea which we don’t want.
 * This is especially true since WooCommerce works on a order row basis (example;
   100 kr for 2 items) while Svea uses unit pricing (example; 50 kr per item, 2 
   items).
 * We’ll have a look at improving our FAQ or similar to include a text about the
   decimals.
 * Best regards
 *  Thread Starter [Rune Rasmussen](https://wordpress.org/support/users/syntaxerrorno/)
 * (@syntaxerrorno)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/decimals-12/#post-17789530)
 * > If you want to display your prices such as “2200 kr” then you can use the snippet
   > provided earlier:
 * As mention that’s not a solution who is good enough for several reasons.
 * > This is especially true since WooCommerce works on a order row basis (example;
   > 100 kr for 2 items) while Svea uses unit pricing (example; 50 kr per item, 
   > 2 items).
 * Then that should probably be considered changed, or you could do the correct 
   calculation beforehand in the plugin.
 * Anyhow you have said the issue is that you get the wrong tax rate from your calculations,
   so if you can pull it directly instead of trying to calculate it, it would end
   up right altogether. 😉

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Decimals’ is closed to new replies.

 * ![](https://ps.w.org/svea-checkout-for-woocommerce/assets/icon-128x128.gif?rev
   =2728301)
 * [Svea Checkout for WooCommerce](https://wordpress.org/plugins/svea-checkout-for-woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/svea-checkout-for-woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/svea-checkout-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/svea-checkout-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/svea-checkout-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/svea-checkout-for-woocommerce/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Rune Rasmussen](https://wordpress.org/support/users/syntaxerrorno/)
 * Last activity: [1 year, 11 months ago](https://wordpress.org/support/topic/decimals-12/#post-17789530)
 * Status: not resolved