diff --git a/beike/Shop/Http/Resources/CartDetail.php b/beike/Shop/Http/Resources/CartDetail.php index df6f9807..ceb00e35 100644 --- a/beike/Shop/Http/Resources/CartDetail.php +++ b/beike/Shop/Http/Resources/CartDetail.php @@ -47,6 +47,7 @@ class CartDetail extends JsonResource 'subtotal' => $subTotal, 'subtotal_format' => currency_format($subTotal), 'variant_labels' => trim($sku->getVariantLabel()), + 'active' => $product->active ]; return hook_filter('resource.cart.detail', $result); diff --git a/beike/Shop/Services/CartService.php b/beike/Shop/Services/CartService.php index 0ba7f8ad..b9af543d 100644 --- a/beike/Shop/Services/CartService.php +++ b/beike/Shop/Services/CartService.php @@ -195,6 +195,13 @@ class CartService if (empty($carts)) { $carts = self::list(current_customer()); } + // 判断:禁止选中 非直接下单产品 + $carts = array_map(function($cartItem){ + if(!$cartItem['active']){ + $cartItem['selected'] = 0; + } + return $cartItem; + },$carts); $cartList = collect($carts)->where('selected', 1); diff --git a/themes/default/cart/cart.blade.php b/themes/default/cart/cart.blade.php index 43104ec9..8c696f7b 100644 --- a/themes/default/cart/cart.blade.php +++ b/themes/default/cart/cart.blade.php @@ -46,7 +46,8 @@
- + +
@@ -57,7 +58,7 @@
- +
@@ -149,12 +150,6 @@ allProduct() { return this.products.map(e => e.quantity).reduce((n,m) => n + m); }, - }, - mounted(){ - - console.log(this.totals); - - }, methods: { checkedBtnToCheckout() { diff --git a/themes/default/cart/mini.blade.php b/themes/default/cart/mini.blade.php index afe16a97..4b3ccf39 100644 --- a/themes/default/cart/mini.blade.php +++ b/themes/default/cart/mini.blade.php @@ -2,6 +2,7 @@
{{ __('shop/carts.mini') }}
+
@php $check = 0 @endphp @@ -10,8 +11,10 @@ @foreach ($carts as $cart) @if ($cart['selected']) @php $check = $check + 1 @endphp @endif
-
- +
+ @if ($cart['active']) + + @endif