PHP Warning: number_format

If you receive the number_format issue, it's due to the way your version of PHP is handling null entries and/or error checking in the number_format function. To correct this, you can initialize the values sent to that function by doing the following:

VERSION 2.72 OR 2.81 (Corrected in 2.82):

  1. Open the product_options.php file in the /enc/ folder.

  2. Change the following code:

    $attributeprice = number_format($attribute[1], 2, '.', '');

    to:

    $attributeprice = number_format((float)$attribute[1], 2, '.', '');
  3. Change the following code:

    $newattprice = number_format($unitprice + $attribute[1], 2, '.', '');

    to:

    $newattprice = number_format(floatval($unitprice + $attribute[1]), 2, '.', '');
  4. Change the following code:

    $attributedisplay .= number_format($regprice + $attribute[1], 2, '.', '');

    to:

    $attributedisplay .= number_format(floatval($regprice + $attribute[1]), 2, '.', '');
  5. Open the attributes.php file in the /includes/ folder of the storeadmin/ folder.

  6. Change the following code:

    $priceval = number_format($priceval, 2, '.', '');

    to:

    $priceval = number_format((float)$priceval, 2, '.', '');
  7. (Added 8/11/14) Open the itemlist.php file in the /storeadmin/ area, and change the following code (around line 431) from:

    if ($itemrow[SalePrice] > 0)
    $itemprice = "" .$itemrow[RegPrice] ." " .$itemrow[SalePrice];
    else
    $itemprice = $itemrow[RegPrice];

    to

    if ($itemrow[SalePrice] > 0)
    $itemprice = $itemrow[SalePrice];
    else
    $itemprice = $itemrow[RegPrice];
  8. In that same file, change the code (around line 456) from:

    echo "" .number_format($itemprice, 2, '.', '') ."";

    to

    echo "" .($itemprice > 0 ? number_format((float)$itemprice, 2, '.', '') : "") ."";
  9. In that same file, change the code (around line 510) from:

    echo "" .number_format($optprice, 2, '.', '') ."";

    to

    echo "" .($optprice > 0 ? number_format((float)$optprice, 2, '.', '') : "") ."";

VERSION 2.72 (Already corrected in 2.81):

  1. In addition to the above, open the order.php file in the /go/ folder.

  2. Change the following code:

    if (!$discountpr)

    to:

    if (!$discountpr AND $price > 0)