优化:非直接购买商品禁止下单(但是可以加入购物车和收藏)
This commit is contained in:
parent
b7a2839ee4
commit
8ab026f52e
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,8 @@
|
|||
<tr v-for="product, index in products" :key="index" :class="product.selected ? 'active' : ''">
|
||||
<td>
|
||||
<div class="d-flex align-items-center p-image">
|
||||
<input class="form-check-input" type="checkbox" @change="checkedCartTr(index)" v-model="product.selected">
|
||||
<input v-if="!product.active" class="form-check-input" type="checkbox" disabled="disabled">
|
||||
<input v-else class="form-check-input" type="checkbox" @change="checkedCartTr(index)" v-model="product.selected">
|
||||
<div class="border d-flex align-items-center justify-content-center wh-80 ms-3"><img :src="product.image_url" class="img-fluid"></div>
|
||||
</div>
|
||||
</td>
|
||||
|
|
@ -57,7 +58,7 @@
|
|||
</td>
|
||||
<td>
|
||||
<div class="quantity-wrap">
|
||||
<input type="text" class="form-control" @input="quantityChange(product.quantity, product.cart_id, product.sku_id)" onkeyup="this.value=this.value.replace(/\D/g,'')" v-model.number="product.quantity" name="quantity" minimum="1">
|
||||
<input type="text" class="form-control" @input="quantityChange(product.quantity, product.cart_id, product.sku_id)" onkeyup="this.value=this.value.replace(/\D/g,'')" v-model.number="product.quantity" name="quantity" minimum="0">
|
||||
<div class="right">
|
||||
<i class="bi bi-chevron-up"></i>
|
||||
<i class="bi bi-chevron-down"></i>
|
||||
|
|
@ -149,12 +150,6 @@
|
|||
allProduct() {
|
||||
return this.products.map(e => e.quantity).reduce((n,m) => n + m);
|
||||
},
|
||||
},
|
||||
mounted(){
|
||||
|
||||
console.log(this.totals);
|
||||
|
||||
|
||||
},
|
||||
methods: {
|
||||
checkedBtnToCheckout() {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
<h5 id="offcanvasRightLabel" class="mx-auto mb-0">{{ __('shop/carts.mini') }}</h5>
|
||||
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<div class="offcanvas-body pt-0">
|
||||
@php $check = 0 @endphp
|
||||
|
||||
|
|
@ -10,8 +11,10 @@
|
|||
@foreach ($carts as $cart)
|
||||
@if ($cart['selected']) @php $check = $check + 1 @endphp @endif
|
||||
<div class="product-list d-flex align-items-center">
|
||||
<div class="select-wrap">
|
||||
<i class="bi {{ $cart['selected'] ? 'bi-check-circle-fill' : 'bi-circle' }}" data-id="{{ $cart['cart_id'] }}"></i>
|
||||
<div class="select-wrap" style="min-width: 20px;">
|
||||
@if ($cart['active'])
|
||||
<i class="bi {{ $cart['selected'] ? 'bi-check-circle-fill' : 'bi-circle' }}" data-id="{{ $cart['cart_id'] }}"></i>
|
||||
@endif
|
||||
</div>
|
||||
<div class="product-info d-flex align-items-center">
|
||||
<div class="left"><a href="{{ shop_route('products.show', $cart['product_id']) }}" class="d-flex justify-content-between align-items-center h-100"><img src="{{ $cart['image_url'] ?: image_resize('', 160, 160) }}" class="img-fluid"></a></div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue