improved conditions check in applying cart rules

This commit is contained in:
Prashant Singh 2019-06-14 19:24:15 +05:30
parent da82f2935c
commit 1e865986c4
7 changed files with 43 additions and 11 deletions

View File

@ -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');

View File

@ -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',

View File

@ -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()
{

View File

@ -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'];
}
}
}

View File

@ -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

View File

@ -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);
});
}
}
});

View File

@ -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