Jump to content

google analytics module php warning on product page


Recommended Posts

[29-Jan-2015 11:21:38 US/Pacific] PHP Warning:  number_format() expects parameter 1 to be double, string given in /home/sites/public_html/modules/ganalytics/ganalytics.php on line 468

 

started getting this warning with the latest update

Share this post


Link to post
Share on other sites
  • 2 weeks later...

The line of code is not adhering to the number_format specification, which requires a float/double.  It is not a problem per say, because the function will auto convert the string to the proper format, but PHP will spit out the warning regardless.

[29-Jan-2015 11:21:38 US/Pacific] PHP Warning:  number_format() expects parameter 1 to be double, string given in /home/sites/public_html/modules/ganalytics/ganalytics.php on line 468

You can get rid of the warning by changing the following line of code in modules/ganalytics/ganalytics.php, which appears on line 468

'price' => number_format($product['price'], '2')

Change it to

'price' => number_format((float)$product['price'], '2')

That will convert the product price from a string to a float, before executing the number_format function

  • Like 2

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More