1

I have a problem in my customer panel myorder tab. In my order i see price 12,125.0000 and QTY: 5.0000 how should i remove decimal from them? it is just in my order and methods that i used is like below:

$block->escapeHtml($_item->getRowTotalInclTax())
$_order->getShippingAmount();
$block->escapeHtml($_item->getQtyOrdered())

All of them has 4 decimal like this 0.0000 Any help?

1

Remove All Decimals :-

$rowTotal = (int)$_item->getRowTotalInclTax(); //12,125
$qtyOrdered = (int)$_item->getQtyOrdered(); //5
0

You can use number_format function of PHP to achieve this.

Below is the basic syntax of number_format function:

number_format(number,decimals,decimalpoint,separator)
  • number: Required. The number to be formatted. If no other parameters are set, the number will be formatted without decimals and with comma (,) as the thousands separator.
  • decimals: Optional. Specifies how many decimals. If this parameter is set, the number will be formatted with a dot (.) as decimal point
  • decimalpoint: Optional. Specifies what string to use for decimal point
  • separator: Optional. Specifies what string to use for thousands separator. Only the first character of separator is used. For example, "xxx" will give the same output as "x"

For example: If you write

<?php
echo number_format("1000000", 2, ".", "");
?>

It will output like 1000000.00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.