coupon applied

This commit is contained in:
shubhammehrotra.symfony@webkul.com 2020-01-15 20:00:55 +05:30
parent 259537a000
commit ac19aa2da3
12 changed files with 213 additions and 70 deletions

View File

@ -1718,6 +1718,28 @@
position: absolute;
}
.checkout-process .coupon-container input {
max-width: 200px;
}
.checkout-process .coupon-container button {
margin: 20px 0;
}
.checkout-process .coupon-container .applied-coupon-details {
font-size: 16px;
margin-bottom: 10px;
}
.checkout-process .coupon-container .applied-coupon-details label:nth-of-type(1) {
color: #26A37C;
}
.checkout-process .coupon-container .rango-close {
cursor: pointer;
margin-left: 5px;
}
.address-container .address-holder {
margin-top: 15px;
}
@ -1731,6 +1753,10 @@
height: 100%;
}
.address-container .address-holder .card h5 {
font-size: 14px;
}
.address-container .address-holder .card ul li {
display: inline-block;
}

View File

@ -26,5 +26,9 @@ class VelocityMetaDataSeeder extends Seeder
'product_policy' => '<div class="col-sm-4 col-xs-12 product-policy-wrapper"><div class="card"><div class="row"><div class="col-sm-2"><i class="rango-van-ship fs40"></i></div><div class="col-sm-10"><span class="font-setting fs20">Free Shippingon Order $20 or More</span></div></div></div></div><div class="col-sm-4 col-xs-12 product-policy-wrapper"><div class="card"><div class="row"><div class="col-sm-2"><i class="rango-exchnage fs40"></i></div><div class="col-sm-10"><span class="font-setting fs20">ProductReplace &amp; Return Available </span></div></div></div></div><div class="col-sm-4 col-xs-12 product-policy-wrapper"><div class="card"><div class="row"><div class="col-sm-2"><i class="rango-exchnage fs40"></i></div><div class="col-sm-10"><span class="font-setting fs20">ProductExchange and EMI Available </span></div></div></div></div>',
]);
DB::table('locales')->where('code', 'en')->update([
'locale_image' => '/themes/velocity/assets/images/flags/en.png'
]);
}
}

View File

@ -1004,6 +1004,30 @@
position: absolute;
}
}
.coupon-container {
input {
max-width: 200px;
}
button {
margin: 20px 0;
}
.applied-coupon-details {
font-size: 16px;
margin-bottom: 10px;
}
.applied-coupon-details label:nth-of-type(1) {
color: $theme-color;
}
.rango-close {
cursor: pointer;
margin-left: 5px;
}
}
}
.address-container {
@ -1018,6 +1042,10 @@
.card {
height: 100%;
h5 {
font-size: 14px;
}
ul {
li {
display: inline-block;

View File

@ -2,3 +2,12 @@
type="file"
name="category_icon_path"
style="position: relative;top: -22px;left: 15px;" />
<image-wrapper
:multiple="false"
input-name="category_icon_path"
:images='"{{ $category->image_url }}"'
:button-label="'{{ __('admin::app.catalog.products.add-image-btn-title') }}'">
</image-wrapper>

View File

@ -0,0 +1,121 @@
@if ($cart)
<script type="text/x-template" id="coupon-component-template">
<div class="coupon-container">
<div class="discount-control">
<form class="custom-form" method="post" @submit.prevent="applyCoupon">
<div class="control-group" :class="[error_message ? 'has-error' : '']">
<input
type="text"
name="code"
class="control"
v-model="coupon_code"
placeholder="{{ __('shop::app.checkout.onepage.enter-coupon-code') }}" />
<div class="control-error">@{{ error_message }}</div>
</div>
<button class="theme-btn light" :disabled="disable_button">{{ __('shop::app.checkout.onepage.apply-coupon') }}</button>
</form>
</div>
<div class="applied-coupon-details" v-if="applied_coupon">
<label>{{ __('shop::app.checkout.total.coupon-applied') }}</label>
<label class="right" style="display: inline-flex; align-items: center;">
<b>@{{ applied_coupon }}</b>
<i class="rango-close fs18" title="{{ __('shop::app.checkout.total.remove-coupon') }}" v-on:click="removeCoupon"></i>
</label>
</div>
</div>
</script>
<script>
Vue.component('coupon-component', {
template: '#coupon-component-template',
inject: ['$validator'],
data: function() {
return {
coupon_code: '',
error_message: '',
applied_coupon: "{{ $cart->coupon_code }}",
route_name: "{{ request()->route()->getName() }}",
disable_button: ("{{ $cart->coupon_code }}" == "" ? false : true),
}
},
methods: {
applyCoupon: function() {
var self = this;
if (! self.coupon_code.length)
return;
self.error_message = null;
self.disable_button = true;
axios.post('{{ route('shop.checkout.cart.coupon.apply') }}', {code: self.coupon_code})
.then(function(response) {
if (response.data.success) {
self.$emit('onApplyCoupon');
self.applied_coupon = self.coupon_code;
self.coupon_code = '';
window.flashMessages = [{'type': 'alert-success', 'message': response.data.message}];
self.$root.addFlashMessages();
self.redirectIfCartPage();
} else {
self.error_message = response.data.message;
}
self.disable_button = false;
})
.catch(function(error) {
self.error_message = error.response.data.message;
self.disable_button = false;
});
},
removeCoupon: function () {
var self = this;
axios.delete('{{ route('shop.checkout.coupon.remove.coupon') }}')
.then(function(response) {
self.$emit('onRemoveCoupon')
self.applied_coupon = '';
self.disable_button = false;
window.flashMessages = [{'type': 'alert-success', 'message': response.data.message}];
self.$root.addFlashMessages();
self.redirectIfCartPage();
})
.catch(function(error) {
window.flashMessages = [{'type': 'alert-error', 'message': error.response.data.message}];
self.$root.addFlashMessages();
});
},
redirectIfCartPage: function() {
if (this.route_name != 'shop.checkout.cart.index')
return;
setTimeout(function() {
window.location.reload();
}, 700);
}
}
});
</script>
@endif

View File

@ -128,6 +128,8 @@
@if ($cart)
<div class="col-4 offset-1 row order-summary-container">
@include('shop::checkout.total.summary', ['cart' => $cart])
<coupon-component></coupon-component>
</div>
@else
<div class="fs16 row col-12">
@ -151,6 +153,8 @@
@endsection
@push('scripts')
@include('shop::checkout.cart.coupon')
<script type="text/javascript">
function removeLink(message) {
if (!confirm(message))

View File

@ -9,6 +9,8 @@
@endsection
@push('scripts')
@include('shop::checkout.cart.coupon')
<script type="text/x-template" id="checkout-template">
<div class="container">
<div id="checkout" class="checkout-process offset-1 row col-11">
@ -36,6 +38,11 @@
<payment-section @onPaymentMethodSelected="paymentMethodSelected($event)">
</payment-section>
<coupon-component
@onApplyCoupon="getOrderSummary"
@onRemoveCoupon="getOrderSummary">
</coupon-component>
</div>
<div

View File

@ -4,7 +4,7 @@
$newProducts = app('Webkul\Velocity\Repositories\Product\ProductRepository')->getNewProducts($count);
@endphp
@if (! empty($newProducts))
@if (! empty($newProducts) && $newProducts->total())
<div class="container-fluid">
<card-list-header heading="{{ __('shop::app.home.new-products') }}">
</card-list-header>

View File

@ -1,9 +1,9 @@
<div class="footer-copy-right">
<span class="fs16">
@if (core()->getConfigData('general.content.footer.footer_content'))
{{ core()->getConfigData('general.content.footer.footer_content') }}
{!! core()->getConfigData('general.content.footer.footer_content') !!}
@else
{{ trans('admin::app.footer.copy-right') }}
{!! trans('admin::app.footer.copy-right') !!}
@endif
</span>
</div>

View File

@ -1,62 +1,6 @@
<header>
<div class="row col-12 remove-padding-margin velocity-divide-page">
<logo-component></logo-component>
<searchbar-component></searchbar-component>
{{-- <div class="row no-margin right">
<div class="col-8 no-padding input-group">
<form
method="GET"
role="search"
id="search-form"
action="{{ route('shop.search.index') }}">
<div
class="btn-toolbar full-width"
role="toolbar">
<div class="btn-group full-width">
<div class="selectdiv">
<select class="form-control fs13 border-right-0" name="category">
<option value="">
{{ __('velocity::app.header.all-categories') }}
</option>
@foreach ($categories as $category)
<option value="{{ $category->id }}">
{{ $category->name }}
</option>
@endforeach
<span class="select-icon rango-arrow-down"></span>
</select>
</div>
<div class="full-width">
<input
required
name="term"
type="search"
class="form-control"
placeholder="{{ __('velocity::app.header.search-text') }}" />
<button class="btn" type="submit" id="header-search-icon">
<i class="fs16 fw6 rango-search"></i>
</button>
</div>
</div>
</div>
</form>
</div>
<div class="col-4">
{!! view_render_event('bagisto.shop.layout.header.cart-item.before') !!}
@include('shop::checkout.cart.mini-cart')
{!! view_render_event('bagisto.shop.layout.header.cart-item.after') !!}
</div>
</div> --}}
</div>
</header>

View File

@ -15,7 +15,7 @@
@endforeach
<div class="locale-icon">
<img src="{{ asset('/storage/' . $localeImage) }}" />
<img src="{{ asset('/storage/' . $localeImage) }}" onerror="this.src = '{{ asset($localeImage) }}'" />
</div>
<select