Skip to content

Commit 7c70140

Browse files
bug fix:generate order, item_count = only cart active product total count, not all cart product
1 parent 34bf4fc commit 7c70140

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

services/cart/Quote.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ public function getCartInfo($activeProduct = true, $shipping_method = '', $count
376376
$products = $cart_product_info['products'];
377377
$product_total = $cart_product_info['product_total'];
378378
$base_product_total = $cart_product_info['base_product_total'];
379+
$product_qty_total = $cart_product_info['product_qty_total'];
379380
//if (!$shipping_method) {
380381
// $shipping_method = Yii::$service->shipping->getDefaultShippingMethod($country,$region,$product_weight);
381382
//}
@@ -398,7 +399,7 @@ public function getCartInfo($activeProduct = true, $shipping_method = '', $count
398399
$this->cartInfo[$cartInfoKey] = [
399400
'cart_id' => $cart_id,
400401
'store' => $cart['store'], // store nme
401-
'items_count' => $cart['items_count'], // 购物车中的产品总数
402+
'items_count' => $product_qty_total, // 因为购物车使用了active,因此生成订单的产品个数 = 购物车中active的产品的总个数(也就是在购物车页面用户勾选的产品的总数),而不是字段 $cart['items_count']
402403
'coupon_code' => $coupon_code, // coupon卷码
403404
'shipping_method' => $shipping_method,
404405
'payment_method' => $cart['payment_method'],

services/cart/QuoteItem.php

+12-7
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ public function getCartProductInfo($activeProduct = true)
211211
$product_total = 0;
212212
$product_weight = 0;
213213
$product_volume_weight = 0;
214+
$base_product_total = 0;
215+
$product_volume = 0;
216+
$product_qty_total = 0;
214217
if ($cart_id) {
215218
if (!isset($this->_cart_product_info[$cart_id])) {
216219
$data = $this->_itemModel->find()->where([
@@ -242,11 +245,12 @@ public function getCartProductInfo($activeProduct = true)
242245
$p_vwt = $product_one['volume_weight'] * $qty;
243246

244247
if ($active == $this->activeStatus) {
245-
$product_total += $product_row_price;
248+
$product_total += $product_row_price;
246249
$base_product_total += $base_product_row_price;
247250
$product_weight += $p_wt;
248251
$product_volume_weight += $p_vwt;
249252
$product_volume += $p_pv;
253+
$product_qty_total += $qty;
250254
}
251255
$productSpuOptions = $this->getProductSpuOptions($product_one);
252256
$products[] = [
@@ -278,12 +282,13 @@ public function getCartProductInfo($activeProduct = true)
278282
}
279283
}
280284
$this->_cart_product_info[$cart_id] = [
281-
'products' => $products,
282-
'product_total' => $product_total,
283-
'base_product_total'=> $base_product_total,
284-
'product_weight' => $product_weight,
285-
'product_volume_weight' => $product_volume_weight,
286-
'product_volume' => $product_volume,
285+
'products' => $products,
286+
'product_qty_total' => $product_qty_total,
287+
'product_total' => $product_total,
288+
'base_product_total' => $base_product_total,
289+
'product_weight' => $product_weight,
290+
'product_volume_weight' => $product_volume_weight,
291+
'product_volume' => $product_volume,
287292

288293
];
289294
}

0 commit comments

Comments
 (0)