Browse Source

fix:购物车图片sku为空默认商品图片

super-yimizi 1 month ago
parent
commit
93de5dc555
1 changed files with 4 additions and 0 deletions
  1. 4 0
      application/api/controller/Cart.php

+ 4 - 0
application/api/controller/Cart.php

@@ -143,6 +143,10 @@ class Cart extends Base
                 unset($list[$key]);
                 continue;
             }
+            // 如果sku 的 图片为空
+            if (empty($item->sku->image)) {
+                $item->sku->image = $item->goods->image;
+            }
             $item['subtotal'] = bcmul($item['nums'], ($item->sku->price ?? $item->goods->price), 2);
             $item->goods->visible(explode(',', 'id,title,price,image,marketprice'));
         }