Decimals
-
I noticed your wrote in a post here recently (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?!
- Trim zeros in prices
The topic ‘Decimals’ is closed to new replies.