provision to remove the couponable and non couponable rule had been added

This commit is contained in:
Prashant Singh 2019-06-08 16:13:17 +05:30
parent c791833425
commit 3c16cbba73
6 changed files with 62 additions and 22 deletions

View File

@ -240,6 +240,7 @@ class Discount
$cart = \Cart::getCart();
$report = array();
$result = 0;
//check conditions
if ($rule->conditions != null) {
$conditions = json_decode(json_decode($rule->conditions));
@ -305,6 +306,48 @@ class Discount
return $report;
}
public function removeNonCoupon()
{
$cart = \Cart::getCart();
$nonCouponAbleRule = $this->cartRuleCart->findWhere([
'cart_id' => $cart->id
]);
if (count($couponAbleRule) && ! $couponAbleRule->first()->cart_rule->use_coupon) {
$result = $nonCouponAbleRule->delete();
if ($result) {
return true;
} else {
return false;
}
} else {
return false;
}
}
public function removeCoupon()
{
$cart = \Cart::getCart();
$couponAbleRule = $this->cartRuleCart->findWhere([
'cart_id' => $cart->id
]);
if (count($couponAbleRule) && $couponAbleRule->first()->cart_rule->use_coupon) {
$result = $couponAbleRule->delete();
if ($result) {
return true;
} else {
return false;
}
} else {
return false;
}
}
protected function testIfAllConditionAreTrue($conditions, $cart) {
$shipping_address = $cart->getShippingAddressAttribute();

View File

@ -276,6 +276,14 @@ class CartController extends Controller
return $nonCouponAbleRules;
}
/**
* To save the discount values inside the tables of orders and cart
*/
public function saveDiscount()
{
return ['hellow'];
}
/**
* To remove the currently active
* couponable rule

View File

@ -41,6 +41,8 @@ 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/save/discounts', 'Webkul\Shop\Http\Controllers\CartController@saveDiscount')->name('shop.checkout.save.discount');
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');

View File

@ -58,7 +58,7 @@
<div class="item-detail">
<label>{{ __('shop::app.checkout.total.disc-amount') }}</label>
<label class="right">@{{ discount_amount }}</label>
<label class="right">@{{ discount_amount }} <span class="icon cross-icon" v-on:click="removeCoupon"></span></label>
</div>
<div class="item-detail" style="font-weight: bold;">
@ -343,6 +343,12 @@
placeOrder: function() {
var this_this = this;
axios.post('{{ route('shop.checkout.save.discount') }}').then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.log('error in saving discount');
});
this.disable_button = true;
this.$http.post("{{ route('shop.checkout.save-order') }}", {'_token': "{{ csrf_token() }}"})
@ -597,15 +603,9 @@
axios.post('{{ route('shop.checkout.remove.coupon') }}', {
code: this_this.code
}).then(function(response) {
if (response.data.message == true) {
this_this.discounted = null;
this_this.discount.amount = null;
this_this.discount.action = null;
this_this.discount.amount_given = null;
this_this.discount.message = null;
}
console.log(response.data);
}).catch(function(error) {
this_this.discounted = false;
console.log(error.data);
});
}
}

View File

@ -87,8 +87,6 @@
</div>
{!! view_render_event('bagisto.shop.checkout.name.after', ['item' => $item]) !!}
{!! view_render_event('bagisto.shop.checkout.price.before', ['item' => $item]) !!}
<div class="row">
@ -101,8 +99,6 @@
</div>
{!! view_render_event('bagisto.shop.checkout.price.after', ['item' => $item]) !!}
{!! view_render_event('bagisto.shop.checkout.quantity.before', ['item' => $item]) !!}
<div class="row">
@ -116,27 +112,21 @@
{!! view_render_event('bagisto.shop.checkout.quantity.after', ['item' => $item]) !!}
@if ($product->type == 'configurable')
{!! view_render_event('bagisto.shop.checkout.options.after', ['item' => $item]) !!}
<div class="summary" >
{{ Cart::getProductAttributeOptionDetails($item->child->product)['html'] }}
</div>
{!! view_render_event('bagisto.shop.checkout.options.after', ['item' => $item]) !!}
@endif
</div>
</div>
@endforeach
</div>
<div class="order-description mt-20">
<div class="pull-left" style="width: 60%; float: left;">
<div class="shipping">
<div class="decorator">

View File

@ -7,7 +7,6 @@
@section('content-wrapper')
<div class="order-success-content" style="min-height: 300px;">
<h1>{{ __('shop::app.checkout.success.thanks') }}</h1>
<p>{{ __('shop::app.checkout.success.order-id-info', ['order_id' => $order->id]) }}</p>
@ -19,7 +18,5 @@
{{ __('shop::app.checkout.cart.continue-shopping') }}
</a>
</div>
</div>
@endsection