diff --git a/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php b/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php index bab8b0b40..a60169235 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php @@ -228,6 +228,12 @@ class OnepageController extends Controller { $cart = Cart::getCart(); + $minimumOrderAmount = (int) core()->getConfigData('sales.orderSettings.minimum-order.minimum_order_amount') ?? 0; + + if (! ($cart->base_sub_total > $minimumOrderAmount)) { + throw new \Exception(trans('shop::app.checkout.cart.minimum-order-message', ['amount' => $minimumOrderAmount])); + } + if ($cart->haveStockableItems() && ! $cart->shipping_address) { throw new \Exception(trans('Please check shipping address.')); } diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/checkout/cart/index.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/checkout/cart/index.blade.php index adb5a99ae..b2b146f08 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/checkout/cart/index.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/checkout/cart/index.blade.php @@ -303,10 +303,10 @@ ], mounted: function () { - let cartDetails = JSON.parse(this.cartDetails); + let cartDetails = this.getCartDetails(); $('#proceed-to-checkout').on('click', (e) => { - if (! (cartDetails.base_grand_total > this.minimumOrderAmount)) { + if (! (cartDetails.base_sub_total > this.minimumOrderAmount)) { e.preventDefault(); window.showAlert(`alert-warning`, 'Warning', this.minimumOrderMessage); } @@ -323,6 +323,10 @@ removeLink(message) { if (! confirm(message)) event.preventDefault(); + }, + + getCartDetails: function () { + return JSON.parse(this.cartDetails); } } }) diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage.blade.php index 1832feeb8..f85bf203a 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage.blade.php @@ -5,7 +5,15 @@ @stop @section('content-wrapper') - + @php + $minimumOrderAmount = (int) core()->getConfigData('sales.orderSettings.minimum-order.minimum_order_amount') ?? 0; + @endphp + + + @endsection @push('scripts') @@ -112,8 +120,15 @@ Vue.component('checkout', { template: '#checkout-template', + inject: ['$validator'], + props: [ + 'cartDetails', + 'minimumOrderAmount', + 'minimumOrderMessage' + ], + data: function () { return { allAddress: {}, @@ -159,6 +174,10 @@ created: function () { this.getOrderSummary(); + if (! (this.getCartDetails().base_sub_total > this.minimumOrderAmount)) { + window.showAlert(`alert-warning`, 'Warning', this.minimumOrderMessage); + } + if (! customerAddress) { this.new_shipping_address = true; this.new_billing_address = true; @@ -544,6 +563,10 @@ setTimeout(() => { this.validateForm('address-form'); }, 0); + }, + + getCartDetails: function () { + return JSON.parse(this.cartDetails); } } });