Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Woocommerce: How to display prices with decimals

On website the prices must be displayed without decimals, but I need to display decimals in the invoice.

For example, Product1 price displayed on website is $ 15. If I change the general settings to hide decimals it will hide decimals in invoice as well, and I need it to be $ 15.00

Is there any way I can do that?

Thanks, Nicu.

like image 872
Nicu Zecheru Avatar asked Mar 04 '15 11:03

Nicu Zecheru


People also ask

How do I add decimal prices in WooCommerce?

If you just wanna do that you can do it by woocommerce settings. Just go to admin dashboard->woocomerce->setting->Genrak tab look for currency option and set Number of decimals.


1 Answers

Running any number through the function woocommerce_price() will format that number with the number of decimals, thousands separator, currency symbol and currency location chosen in the admin.

Add the function to your code snippet should format the price correctly:

<?php if ( $price_html = $product->get_price_including_tax() ): ?>
<span class="price"><?php echo woocommerce_price($price_html); ?></span>

Source: https://wordpress.stackexchange.com/questions/106355/how-to-display-price-including-tax-with-formatting

like image 160
DrawdeX Avatar answered Sep 19 '22 15:09

DrawdeX