Fixed discount on frontend
This commit is contained in:
parent
8d68be8e07
commit
eaa755bbea
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue