improved conditions check in applying cart rules
This commit is contained in:
parent
da82f2935c
commit
1e865986c4
|
|
@ -649,7 +649,7 @@ Route::group(['middleware' => ['web']], function () {
|
|||
|
||||
// Route::post('fetch/options', 'Webkul\Discount\Http\Controllers\CatalogRuleController@fetchAttributeOptions')->name('admin.catalog-rule.options');
|
||||
|
||||
Route::get('/cart-rule', 'Webkul\Discount\Http\Controllers\CartRuleController@index')->defaults('_config', [
|
||||
Route::get('/cart-rules', 'Webkul\Discount\Http\Controllers\CartRuleController@index')->defaults('_config', [
|
||||
'view' => 'admin::promotions.cart-rule.index'
|
||||
])->name('admin.cart-rule.index');
|
||||
|
||||
|
|
|
|||
|
|
@ -799,7 +799,7 @@ return [
|
|||
|
||||
'promotion' => [
|
||||
'catalog-rule' => 'Catalog Rules',
|
||||
'cart-rule' => 'Cart Rule',
|
||||
'cart-rule' => 'Cart Rules',
|
||||
'add-catalog-rule' => 'Add Catalog Rule',
|
||||
'add-cart-rule' => 'Add Cart Rule',
|
||||
'edit-cart-rule' => 'Edit Cart Rule',
|
||||
|
|
|
|||
|
|
@ -1277,12 +1277,12 @@ class Cart {
|
|||
return true;
|
||||
}
|
||||
|
||||
// public function removeCoupon()
|
||||
// {
|
||||
// $result = $this->discount->removeCoupon();
|
||||
public function removeCoupon()
|
||||
{
|
||||
$result = $this->discount->removeCoupon();
|
||||
|
||||
// return $result;
|
||||
// }
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function leastWorthItem()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -369,10 +369,22 @@ class Discount
|
|||
if ($cart->items_qty >= $disc_threshold && $realQty >= $disc_quantity) {
|
||||
if ($action_type == config('pricerules.cart.validation.0')) {
|
||||
$amountDiscounted = $leastWorthItem['total'] * ($disc_amount / 100);
|
||||
|
||||
if ($amountDiscounted > $leastWorthItem['total']) {
|
||||
$amountDiscounted = $leastWorthItem['total'];
|
||||
}
|
||||
} else if ($action_type == config('pricerules.cart.validation.1')) {
|
||||
$amountDiscounted = $disc_amount;
|
||||
|
||||
if ($amountDiscounted > $leastWorthItem['total']) {
|
||||
$amountDiscounted = $leastWorthItem['total'];
|
||||
}
|
||||
} else if ($action_type == config('pricerules.cart.validation.2')) {
|
||||
$amountDiscounted = $disc_amount;
|
||||
|
||||
if ($amountDiscounted > $leastWorthItem['total']) {
|
||||
$amountDiscounted = $leastWorthItem['total'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,6 @@ Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function
|
|||
|
||||
Route::post('checkout/check/coupons', 'Webkul\Shop\Http\Controllers\CartController@applyCoupon')->name('shop.checkout.check.coupons');
|
||||
|
||||
Route::post('checkout/fetch/noncoupon', 'Webkul\Shop\Http\Controllers\CartController@getNonCouponAbleRule')->name('shop.checkout.fetch.non-coupon');
|
||||
|
||||
Route::post('checkout/remove/coupon', 'Webkul\Shop\Http\Controllers\CartController@removeCoupon')->name('shop.checkout.remove.coupon');
|
||||
|
||||
//Cart Items Add
|
||||
|
|
|
|||
|
|
@ -388,6 +388,17 @@
|
|||
console.log(error.data);
|
||||
});
|
||||
},
|
||||
|
||||
removeCoupon: function () {
|
||||
var this_this = this;
|
||||
|
||||
axios.post('{{ route('shop.checkout.remove.coupon') }}')
|
||||
.then(function(response) {
|
||||
console.log(response.data);
|
||||
}).catch(function(error) {
|
||||
console.log(error.data);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -507,7 +518,7 @@
|
|||
},
|
||||
|
||||
methods: {
|
||||
onSubmit: function() {
|
||||
onSubmit: function () {
|
||||
var this_this = this;
|
||||
|
||||
axios.post('{{ route('shop.checkout.check.coupons') }}', {
|
||||
|
|
@ -517,6 +528,17 @@
|
|||
}).catch(function(error) {
|
||||
console.log(error.data);
|
||||
});
|
||||
},
|
||||
|
||||
removeCoupon: function () {
|
||||
var this_this = this;
|
||||
|
||||
axios.post('{{ route('shop.checkout.remove.coupon') }}')
|
||||
.then(function(response) {
|
||||
console.log(response.data);
|
||||
}).catch(function(error) {
|
||||
console.log(error.data);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
<div class="discount-details-group">
|
||||
<div class="item-detail">
|
||||
<label>{{ __('shop::app.checkout.total.coupon-applied') }}</label>
|
||||
<label class="right" style="display: inline-flex; align-items: center;">{{ $cart->coupon_code }} <span class="icon cross-icon" title="{{ __('shop::app.checkout.total.remove-coupon') }}"></span></label>
|
||||
<label class="right" style="display: inline-flex; align-items: center;">{{ $cart->coupon_code }} <span class="icon cross-icon" title="{{ __('shop::app.checkout.total.remove-coupon') }}" v-on:click="removeCoupon"></span></label>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue