I'm trying to modify a pseudo-shopping cart (it's array based storing values in user meta and not database) PHP file that wrongly displays currency > 1000 as 0.01
Here's the block I want to change:
public function get_cart_value()
{
$cart = $this->cart;
$prices = array();
$cart = apply_filters('ss_mod_cart_value', $cart);
foreach ($cart['products'] as $product)
{
array_push( $prices, array('price'=>trim($product['price']), 'discount' => trim($product['discount'] )));
}
$total = 0;
foreach($prices as $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 it works on will correctly display the total values of items less than 4 digits, for example:
300 + 500 = 800
but
300 + 500 + 1000 = 800.01
instead of 1,800
I've been trying to change number_format()
to make it work but cannot find a solution.