Merge pull request #1045 from jitendra-webkul/jitendra
Checkout coupon apply issue fixed
This commit is contained in:
commit
bac887b0a3
|
|
@ -83,7 +83,7 @@ class CartRuleController extends Controller
|
|||
*/
|
||||
public function store()
|
||||
{
|
||||
$validated = $this->validate($data, [
|
||||
$validated = $this->validate(request(), [
|
||||
'name' => 'required|string',
|
||||
'description' => 'string',
|
||||
'customer_groups' => 'required|array',
|
||||
|
|
|
|||
|
|
@ -72,7 +72,11 @@
|
|||
</div>
|
||||
|
||||
<div class="step-content review" v-show="currentStep == 4" id="summary-section">
|
||||
<review-section v-if="currentStep == 4" hide-discount="1"></review-section>
|
||||
<review-section v-if="currentStep == 4">
|
||||
<div slot="summary-section" v-if="resetSummary">
|
||||
<summary-section discount="1" @onApplyCoupon="getOrderSummary" @onRemoveCoupon="getOrderSummary"></summary-section>
|
||||
</div>
|
||||
</review-section>
|
||||
|
||||
<div class="button-group">
|
||||
<button type="button" class="btn btn-lg btn-primary" @click="placeOrder()" :disabled="disable_button" id="checkout-place-order-button">
|
||||
|
|
@ -83,7 +87,7 @@
|
|||
</div>
|
||||
|
||||
<div class="col-right" v-if="resetSummary" v-show="currentStep != 4">
|
||||
<summary-section hide-discount="1"></summary-section>
|
||||
<summary-section></summary-section>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
|
@ -203,7 +207,7 @@
|
|||
|
||||
setTimeout(function() {
|
||||
this_this.resetSummary = true;
|
||||
}, 0);
|
||||
}, 500);
|
||||
})
|
||||
.catch(function (error) {})
|
||||
},
|
||||
|
|
@ -341,67 +345,6 @@
|
|||
}
|
||||
})
|
||||
|
||||
var summaryTemplateRenderFns = [];
|
||||
|
||||
Vue.component('summary-section', {
|
||||
inject: ['$validator'],
|
||||
|
||||
data: function() {
|
||||
return {
|
||||
templateRender: null,
|
||||
|
||||
code: null,
|
||||
|
||||
coupon_used: false,
|
||||
|
||||
hide_discount: 0
|
||||
}
|
||||
},
|
||||
|
||||
staticRenderFns: summaryTemplateRenderFns,
|
||||
|
||||
mounted: function() {
|
||||
this.templateRender = summaryHtml.render;
|
||||
|
||||
for (var i in summaryHtml.staticRenderFns) {
|
||||
summaryTemplateRenderFns.push(summaryHtml.staticRenderFns[i]);
|
||||
}
|
||||
},
|
||||
|
||||
render: function(h) {
|
||||
return h('div', [
|
||||
(this.templateRender ?
|
||||
this.templateRender() :
|
||||
'')
|
||||
]);
|
||||
},
|
||||
|
||||
methods: {
|
||||
onSubmit: function() {
|
||||
var this_this = this;
|
||||
|
||||
axios.post('{{ route('shop.checkout.check.coupons') }}', {
|
||||
code: this_this.code
|
||||
}).then(function(response) {
|
||||
console.log(response.data);
|
||||
}).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);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var shippingTemplateRenderFns = [];
|
||||
|
||||
Vue.component('shipping-section', {
|
||||
|
|
@ -490,32 +433,65 @@
|
|||
var reviewTemplateRenderFns = [];
|
||||
|
||||
Vue.component('review-section', {
|
||||
props: ['resetSummary'],
|
||||
|
||||
data: function() {
|
||||
return {
|
||||
templateRender: null,
|
||||
|
||||
code: '',
|
||||
|
||||
hide_discount: 1,
|
||||
|
||||
coupon_used: false,
|
||||
|
||||
error_message: ''
|
||||
}
|
||||
},
|
||||
|
||||
staticRenderFns: reviewTemplateRenderFns,
|
||||
|
||||
render: function(h) {
|
||||
return h('div', [
|
||||
(this.templateRender ?
|
||||
this.templateRender() :
|
||||
'')
|
||||
]);
|
||||
},
|
||||
|
||||
mounted: function() {
|
||||
this.templateRender = reviewHtml.render;
|
||||
|
||||
for (var i in reviewHtml.staticRenderFns) {
|
||||
reviewTemplateRenderFns.push(reviewHtml.staticRenderFns[i]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@if ($cart->coupon_code != null)
|
||||
this.code = '{{ $cart->coupon_code }}';
|
||||
this.coupon_used = true;
|
||||
@endif
|
||||
|
||||
var summaryTemplateRenderFns = [];
|
||||
|
||||
Vue.component('summary-section', {
|
||||
inject: ['$validator'],
|
||||
|
||||
props: {
|
||||
discount: {
|
||||
type: [String, Number],
|
||||
|
||||
default: 0,
|
||||
}
|
||||
},
|
||||
|
||||
data: function() {
|
||||
return {
|
||||
templateRender: null,
|
||||
|
||||
error_message: ''
|
||||
}
|
||||
},
|
||||
|
||||
staticRenderFns: summaryTemplateRenderFns,
|
||||
|
||||
mounted: function() {
|
||||
this.templateRender = summaryHtml.render;
|
||||
|
||||
for (var i in summaryHtml.staticRenderFns) {
|
||||
summaryTemplateRenderFns.push(summaryHtml.staticRenderFns[i]);
|
||||
}
|
||||
},
|
||||
|
||||
render: function(h) {
|
||||
|
|
@ -527,45 +503,27 @@
|
|||
},
|
||||
|
||||
methods: {
|
||||
onSubmit: function () {
|
||||
onSubmit: function() {
|
||||
var this_this = this;
|
||||
|
||||
axios.post('{{ route('shop.checkout.check.coupons') }}', {
|
||||
code: this_this.code
|
||||
}).then(function(response) {
|
||||
this_this.coupon_used = true;
|
||||
|
||||
document.getElementById("discount-detail").style.display = "block";
|
||||
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);
|
||||
});
|
||||
axios.post('{{ route('shop.checkout.check.coupons') }}', {code: this_this.code})
|
||||
.then(function(response) {
|
||||
this_this.$emit('onApplyCoupon')
|
||||
})
|
||||
.catch(function(error) {});
|
||||
},
|
||||
|
||||
removeCoupon: function () {
|
||||
var this_this = this;
|
||||
|
||||
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);
|
||||
|
||||
this_this.error_message = '{{ __('shop::app.checkout.onepage.total.cannot-apply-coupon') }}'
|
||||
});
|
||||
.then(function(response) {
|
||||
this_this.$emit('onRemoveCoupon')
|
||||
})
|
||||
.catch(function(error) {});
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
@endpush
|
||||
|
|
@ -155,7 +155,7 @@
|
|||
</div>
|
||||
|
||||
<div class="pull-right" style="width: 40%; float: left;">
|
||||
@include('shop::checkout.total.summary', ['cart' => $cart])
|
||||
<slot name="summary-section"></slot>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -44,28 +44,35 @@
|
|||
</label>
|
||||
</div>
|
||||
|
||||
<div @if (! request()->is('checkout/cart')) v-if="hide_discount" @endif>
|
||||
<div @if (! request()->is('checkout/cart')) v-if="parseInt(discount)" @endif>
|
||||
@if (! request()->is('checkout/cart'))
|
||||
<div class="discount">
|
||||
<div class="discount-group" v-if="! coupon_used">
|
||||
<form class="coupon-form" method="post" @submit.prevent="onSubmit">
|
||||
<div class="control-group mt-20" :class="[errors.has('code') ? 'has-error' : '']">
|
||||
<input type="text" class="control" value="" v-model="code" name="code" placeholder="Enter Coupon Code" v-validate="'required'" style="width: 100%">
|
||||
</div>
|
||||
@if (! $cart->coupon_code)
|
||||
<div class="discount">
|
||||
<div class="discount-group">
|
||||
<form class="coupon-form" method="post" @submit.prevent="onSubmit">
|
||||
<div class="control-group mt-20" :class="[errors.has('code') ? 'has-error' : '']">
|
||||
<input type="text" class="control" value="" v-model="code" name="code" placeholder="Enter Coupon Code" v-validate="'required'" style="width: 100%">
|
||||
</div>
|
||||
|
||||
<span class="control-error" v-if="error_message.length > 0">@{{ error_message }}</span>
|
||||
<span class="control-error" v-if="error_message.length > 0">@{{ error_message }}</span>
|
||||
|
||||
<button class="btn btn-lg btn-black">{{ __('shop::app.checkout.onepage.apply-coupon') }}</button>
|
||||
</form>
|
||||
<button class="btn btn-lg btn-black">{{ __('shop::app.checkout.onepage.apply-coupon') }}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
<div class="discount-details-group">
|
||||
<div class="item-detail">
|
||||
<label>{{ __('shop::app.checkout.total.coupon-applied') }}</label>
|
||||
|
||||
<div class="discount-details-group" v-if="coupon_used">
|
||||
<div class="item-detail">
|
||||
<label>{{ __('shop::app.checkout.total.coupon-applied') }}</label>
|
||||
<label class="right" style="display: inline-flex; align-items: center;"><b>@{{ code }}</b><span class="icon cross-icon" title="{{ __('shop::app.checkout.total.remove-coupon') }}" v-on:click="removeCoupon"></span></label>
|
||||
<label class="right" style="display: inline-flex; align-items: center;">
|
||||
<b>{{ $cart->coupon_code }}</b>
|
||||
|
||||
<span class="icon cross-icon" title="{{ __('shop::app.checkout.total.remove-coupon') }}" v-on:click="removeCoupon"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
Loading…
Reference in New Issue