Authored by Rock Zhang

修复购物车加价购商品显示选择框的bug

... ... @@ -664,14 +664,7 @@ class CartModel
$sizeList[$val['color_id']][] = $oneSize;
$colorStorageGroup[$one['size_name']][$val['color_name']] = $one['storage_number'];
}
// 统计尺码对应的各个颜色的库存量
foreach ($sizes as $colorId => $sizeArr) {
foreach ($sizeArr as $key => $value) {
$sizeList[$colorId][$key]['colorNumStr'] = implode('/', array_values($colorStorageGroup[ $sizeArr['name'] ]) );
}
$colorStorageGroup[$one['productSkc']][$val['sizeName']] = $val['storage_number'];
}
// 颜色
... ... @@ -695,9 +688,24 @@ class CartModel
$totalStorageNum += $colorNum;
}
// 遍历所有尺码,统计出该尺码的每个颜色的库存量,没有时添0,不能空着,因为JS中需要判断
foreach ($sizeList as $skc => $sizeArr) {
foreach ($sizeArr as $key => $value) {
$sizeStorageStr = '';
foreach ($colorStorageGroup as $colorArr) {
if (isset($colorArr[ $value['name'] ])) {
$sizeStorageStr .= $colorArr[ $value['name'] ] . '/';
} else {
$sizeStorageStr .= '0/';
}
}
$sizeList[$skc][$key]['colorNumStr'] = rtrim($sizeStorageStr, '/');
}
}
// 格式化尺码对应的各个颜色分组
foreach ($colors as $color) {
$sizes[]['size'] = $sizeList[$color['id']];
$sizes[]['size'] = $sizeList[$color['skcId']];
}
$data['thumbs'] = $thumbImageList;
... ...