php - Displaying currency values greater than 1000 -


i'm trying modify pseudo-shopping cart (it's array based storing values in user meta , not database) php file wrongly displays currency > 1000 0.01

here's block want change:

public function get_cart_value() {     $cart = $this->cart;     $prices = array();      $cart = apply_filters('ss_mod_cart_value', $cart);      foreach ($cart['products'] $product)     {         array_push( $prices, array('price'=>trim($product['price']), 'discount' => trim($product['discount'] )));                 }      $total = 0;      foreach($prices $price)     {         $price = $this->calc_discount($price['price'], $price['discount']);             $price = str_replace('.', '',  $price['final_price']);         $total += $price;     }       $total = number_format($total/100, 2);      return $total; } 

the cart button works on correctly display total values of items less 4 digits, example:

300 + 500 = 800  

but

300 + 500 + 1000 = 800.01 instead of 1,800

i've been trying change number_format() make work cannot find solution.

i think line

$price = str_replace('.', '',  $price['final_price']); 

300+500+ "1000";

your numbers 1,000 converted string , total becomes 801.

you have convert float in proper way suggested in this

php: unformat money


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -