I would like to ask for help, as I am not a dev and dont understand PHP.
I have the "PDF Invoice" plugin for WooCommerce on my Wordpress site.
And it has a modification to display the tax rate instead of the tax value on the invoice.
'<tr>' .
'<td valign="top" width="7%" align="left">' . $item['qty'] . ' x</td>' .
'<td valign="top" width="13%">' . $_product->get_sku() . '</td>' .
'<td valign="top" width="48%">' . stripslashes( $item_name ) . '</td>' .
'<td valign="top" width="12%" align="right">' . wc_price( $item['line_subtotal'] / $item['qty'], array( 'currency' => $order_currency ) ) . '</td>' .
'<td valign="top" width="10%" align="right">' . 100 * ( $item['line_subtotal_tax']/$item['line_subtotal'] ) . '%' . '</td>' .
'<td valign="top" width="10%" align="right">' . wc_price( ( $item['line_subtotal'] + $item['line_subtotal_tax'] ) / $item['qty'], array( 'currency' => $order_currency ) ). '</td>' .
'</tr>';
The following line is supposed to do the tax rate calculation:
'<td valign="top" width="10%" align="right">' . 100 * ( $item['line_subtotal_tax']/$item['line_subtotal'] ) . '%' . '</td>' .
However, the result shows the tax rate with a lot of decimals, like this 7.67178118746%
So the question is, how can I modify the line above to display only one decimal rounded upwards.
So the result I need there is 7.7%
Thanks in advance and best Regards,
Alex
question from:
https://stackoverflow.com/questions/65858561/woocommerce-pdf-invoice-round-tax-rate-to-one-decimal 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…