A-A+
Warning: number_format() expects parameter
ecshop 的订单问题已经出现多次了,尤其是在提交订单的时候,今天又有客户反应,在提交商品订单的时候提示如下的 bug:
Warning:number_format() expects parameter 1 to be double, string given in…
出现这样的问题是因为其配送插件里面的免费额度为 0,所以导致了 $price 的值为空值,直接调用 number+format 的时候出现了错误,下面夏日博客就来说一下其解决的方法,对了,如果没有使用配送插件的话基本不会出现这个问题。。
首先打开 includes/lib+common.php,搜索 number_format,找到如下的代码:
- else
- {
- $price = number_format($price, 2, '.', ”);
- }
- //修改为:
- else
- {
- if(!$price){
- $price = 0;
- }
- $price = number_format($price, 2, '.', ”);
- }
注意:ecshop 本身的 bug 并不多,当出现问题的时候,首先要想想自己是否使用了什么插件或者更改过什么文件,只要找到问题的根源,这样的 bug 就很容易解决了。