1

I am getting the cart information using soap api. But in the result, the price show the 4 digit after decimal place, but i want it 2 digit after decimal place. For example, right now it displaying "3.0000" but i want to display "3.00".

  • General remark: You should handle this in the receiving application. You want to keep the most information in the price while sending it to a different party. – RichardBernards Nov 14 '14 at 08:47

1 Answers1

-1

You can use this php function for specific format

<?php   
     /* english notation without thousands separator*/
         $english_format_number = number_format($number, 2, '.', '');
     /* 1234.57 */ 
?>
  • Thanks for your response. The problem is cart info return total, subtotal, tax amount, shipping cost and many other information in 4 digit after decimal place. so i have to use above function many time in my code. Is there any shortcut or magento function using which i can format the whole cart information in 2 digit after decimal place? – Jignesh Patel Nov 14 '14 at 09:38
  • You can use this function Mage::helper('checkout')->formatPrice(3000.1231); – Emipro Technologies Pvt. Ltd. Nov 14 '14 at 09:40
  • Ok, but where to use this function? I am using cart info api for display cart information. – Jignesh Patel Nov 14 '14 at 09:53
  • The answer is not specifically targeted at Magento. To do it like this in a Magento codebase is just plain wrong! Using the formatPrice() method is a better way to go, but not taylored for the SOAP API as asked... – RichardBernards Nov 14 '14 at 10:04