Fixed discount on frontend

This commit is contained in:
Prashant Singh 2019-06-15 13:13:07 +05:30
parent 8d68be8e07
commit eaa755bbea
3 changed files with 17 additions and 4 deletions

View File

@ -310,6 +310,8 @@ class Discount
\Cart::collectTotals();
$report['grand_total'] = core()->currency(\Cart::getCart()->grand_total);
break;
}
}
@ -471,7 +473,6 @@ class Discount
if ($existingRule->count()) {
if ($existingRule->first()->delete()) {
foreach ($cart->items as $item) {
if ($item->discount_amount > 0) {
$item->update([
@ -489,6 +490,8 @@ class Discount
'base_discount_amount' => 0
]);
\Cart::collectTotals();
return true;
} else {
return false;

View File

@ -305,12 +305,16 @@ class CartController extends Controller
if ($result) {
return response()->json([
'success' => true,
'message' => trans('admin::app.promotion.status.coupon-removed')
'message' => trans('admin::app.promotion.status.coupon-removed'),
'data' => [
'grand_total' => core()->currency(Cart::getCart()->grand_total)
]
]);
} else {
return response()->json([
'success' => false,
'message' => trans('admin::app.promotion.status.coupon-remove-failed')
'message' => trans('admin::app.promotion.status.coupon-remove-failed'),
'data' => null
]);
}
}

View File

@ -538,7 +538,7 @@
document.getElementById("discount-detail").style.display = "block";
document.getElementById("discount-detail-discount-amount").innerHTML = response.data.result.formatted_discount;
document.getElementById("discount-detail-discount-amount").innerHTML = response.data.result.formatted_discount;
document.getElementById("grand-total-amount-detail").innerHTML = response.data.result.grand_total;
}).catch(function(error) {
console.log(error.data);
});
@ -550,8 +550,14 @@
axios.post('{{ route('shop.checkout.remove.coupon') }}')
.then(function(response) {
this_this.coupon_used = false;
this_this.code = '';
console.log(response.data.data.grand_total);
document.getElementById("discount-detail").style.display = "none";
document.getElementById("grand-total-amount-detail").innerHTML = response.data.data.grand_total;
}).catch(function(error) {
console.log(error.data);