Rounding of €
-
Hello,
We are having problems with rounding of € values in our invoices in the most prominent ‘total’ field, making them integers.
We were looking into where the value comes from; it looks like the pdf plugin reads the woocommerce total like so:jsx $totals = apply_filters( 'wpo_wcpdf_raw_order_totals', $this->order->get_order_item_totals(), $this->order );
i.e. only using woocommerce API; and further
jsx add_filter('woocommerce_get_formatted_order_total', function($formatted_total, $self) { return $self->get_total(); }, 10, 2);
got us already rounded value. Probing further, we found that the value is apparently
stored somewhere, already formatted, since the setterphp public function set_total( $value, $deprecated = '' ) { if ( $deprecated ) { wc_deprecated_argument( 'total_type', '3.0', 'Use dedicated total setter methods instead.' ); return $this->legacy_set_total( $value, $deprecated ); } $this->set_prop( 'total', wc_format_decimal( $value, wc_get_price_decimals() ) ); }
either formates the value using
wc_format_decimal( $value, wc_get_price_decimals() )
(removal of this line changed nothing)or stores the value in metadata like so in the deprecated method:
php case 'total' : $amount = wc_format_decimal( $amount, wc_get_price_decimals() ); $this->set_total( $amount ); update_post_meta( $this->get_id(), '_order_total', $amount ); break;
But there are no ‘_order_total’ keys in (*order_itemmeta) table. Anyway, we came to the conclusion this behaviour is most likely a bug, since everything else has proper rounding; values in the database (*order_itemmeta) are having the decimal part.
Thank you for your help.
- The topic ‘Rounding of €’ is closed to new replies.