ecshop订单中配送方式报错

警告内容:Warning: number_format() expects parameter 1 to be double, string given in D:wampwwwecshop_oldincludeslib_common.php on line 966

解决这个问题的时候,一开始我也是先到网上查看相关的解决方案,

大部分都说是lib_common.php的price_format ()里面的$price变量没有判断$price为空时调用number_format()函数出错,

然而ecshop2.7.3上面已经加了相应的判断:if($price==='') { $price=0; }

  所以问题不在这儿,我又找到了订单里面编辑配送方式的对应的代码,发现$shipping_list[$key]['free_money'] = price_format($shipping['configure']['free_money'])的这个里面 的$shipping['configure']是序列化的,但是ecshop里面并没有进行反序列化的处理,所以导 致$shipping['configure']['free_money']的值是'a',这样在price_format ()里面并没有判断他不是数字,所以出错,现在的思路已经清晰了,只要更改将$shipping['configure']进行反序列化的处理,然后获得 相应free_money的值,就可以解决问题了,详细的更改代码:

将:admin/order.php的2201行的$shipping_list[$key]['free_money'] = price_format($shipping['configure']['free_money'])这行代码先注释掉,然后加上一下代码:

    $shipping['configure'] = unserialize($shipping['configure']);
            $sun_shipping = array();
            foreach($shipping['configure'] as $row){
                $sun_shipping[$row['name']] = $row['value'];
            }
            $shipping_list[$key]['free_money'] = price_format($sun_shipping['free_money']);

转载:http://blog.csdn.net/darkvangel/article/details/34451851

原文地址:https://www.cnblogs.com/wawahaha/p/4751845.html