Browse Source

购物车

lizhen_gitee 10 months ago
parent
commit
e5990b794a
1 changed files with 3 additions and 0 deletions
  1. 3 0
      addons/unishop/controller/Cart.php

+ 3 - 0
addons/unishop/controller/Cart.php

@@ -68,6 +68,7 @@ class Cart extends Base
         $productExtend = new \addons\unishop\extend\Product;
 
         $choose_price_total = 0;//已选中的总价格
+        $choose_number = 0;//已选中的个数
         foreach ($carts as $item) {
             $oldProduct = json_decode($item['snapshot'], true);
             $oldData = $productExtend->getBaseData($oldProduct, $item['spec'] ?? '');
@@ -104,6 +105,7 @@ class Cart extends Base
             //已选中商品,总价格
             if($item['choose'] == 1){
                 $choose_price_total = bcadd($choose_price_total,$tempData['Price_total'],2);
+                $choose_number += $tempData['number'];
             }
 
             $tempData['product_id'] = Hashids::encodeHex($item['product_id']);
@@ -113,6 +115,7 @@ class Cart extends Base
 
         $result = [
             'choose_price_total' => $choose_price_total,
+            'choose_number' => $choose_number,
             'list' => $data,
         ];
         $this->success('', $result);