diff --git a/beike/Shop/Http/Resources/ProductDetail.php b/beike/Shop/Http/Resources/ProductDetail.php index 97e2f851..573279a9 100644 --- a/beike/Shop/Http/Resources/ProductDetail.php +++ b/beike/Shop/Http/Resources/ProductDetail.php @@ -54,6 +54,7 @@ class ProductDetail extends JsonResource 'in_wishlist' => $this->inCurrentWishlist->id ?? 0, 'active' => (bool) $this->active, 'price_setting' => $this->price_setting ?? '', + 'minimum_order' => $this->minimum_order ?? 0, 'numPrices' => NumPricesDetail::collection($this->numprices)->jsonSerialize() ?? '', ]; } diff --git a/resources/lang/en/product.php b/resources/lang/en/product.php index 327bba35..c13bdb07 100644 --- a/resources/lang/en/product.php +++ b/resources/lang/en/product.php @@ -28,5 +28,6 @@ return [ 'active' => 'Active', 'inactive' => 'Inactive', 'has_been_inactive' => 'The product has been inactive', - 'minimum_order' => 'Min Order' + 'minimum_order' => 'Min Order', + 'minimum_order_error' => 'The purchase quantity must be greater than or equal to :num' ]; diff --git a/resources/lang/zh_cn/product.php b/resources/lang/zh_cn/product.php index b2a31e65..3efe739d 100644 --- a/resources/lang/zh_cn/product.php +++ b/resources/lang/zh_cn/product.php @@ -29,5 +29,6 @@ return [ 'active' => '上架', 'inactive' => '下架', 'has_been_inactive' => '该商品已下架', - 'minimum_order' => '起订量' + 'minimum_order' => '起订量', + 'minimum_order_error' => '采购数量必须大于等于:num' ]; diff --git a/themes/default/product/product.blade.php b/themes/default/product/product.blade.php index 55138725..798d9810 100644 --- a/themes/default/product/product.blade.php +++ b/themes/default/product/product.blade.php @@ -221,12 +221,18 @@ @endif @hookwrapper('product.detail.sku') -
SKU:@{{ product.sku }}
+
+ SKU:@{{ product.sku }} +
@endhookwrapper @hookwrapper('product.detail.model')
{{ __('shop/products.model') }}: @{{ product.model }}
@endhookwrapper + +
+ {{__('product.minimum_order')}}: @{{ minimum_order }} +
@if (0)
@@ -589,6 +595,7 @@ product_id: "{{$product_id}}", price_setting: @json($product['price_setting'] ?? 'sku'), numPrices: @json($product['numPrices'] ?? []), + minimum_order: @json($product['minimum_order'] ?? 0), centerDialogVisable: false, // 设置显示框的状态 registerForm: { // 添加的信息 contacts: '', @@ -833,6 +840,11 @@ layer.msg('{{ __('shop/products.quantity_error') }}'); return; } + // 判断:当前商品购买数量是否大于等于最小起订量 + if(_this.minimum_order > total){ + layer.msg('{{ __('product.minimum_order_error',['num'=>$product['minimum_order']]) }}'); + return; + } // 请求参数 params = { isBuyNow, @@ -845,6 +857,11 @@ layer.msg('{{ __('shop/products.quantity_error') }}'); return; } + // 判断:当前商品购买数量是否大于等于最小起订量 + if(_this.minimum_order > _this.quantity){ + layer.msg('{{ __('product.minimum_order_error',['num'=>$product['minimum_order']]) }}'); + return; + } // 请求参数 params = { sku_id: _this.product.id, @@ -856,6 +873,13 @@ params.products_country_id = _this.country_id; params.change_logistics_id = _this.change_logistics_id; + + console.log(_this.minimum_order); + + + return false; + + // 提交内容 bk.addCart(params, null, () => { if (isIframe) {