Merge branch 'development' of http://github.com/prashant-webkul/bagisto into development
This commit is contained in:
commit
f460de584c
|
|
@ -801,7 +801,8 @@ return [
|
|||
'apply-percent' => 'Apply as percentage',
|
||||
'apply-fixed' => 'Apply as fixed amount',
|
||||
'adjust-to-percent' => 'Adjust to percentage',
|
||||
'adjust-to-value' => 'Adjust to discount value'
|
||||
'adjust-to-value' => 'Adjust to discount value',
|
||||
'condition-missing' => 'Please check conditons, some values might be missing'
|
||||
],
|
||||
'cart' => [
|
||||
'buy-atleast' => 'Buy Atleast (N)',
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
@elseif ($error = session('error'))
|
||||
window.flashMessages = [{'type': 'alert-error', 'message': "{{ $error }}" }];
|
||||
@elseif ($info = session('info'))
|
||||
window.flashMessages = [{'type': 'alert-error', 'message': "{{ $info }}" }];
|
||||
window.flashMessages = [{'type': 'alert-info', 'message': "{{ $info }}" }];
|
||||
@endif
|
||||
|
||||
window.serverErrors = [];
|
||||
|
|
|
|||
|
|
@ -6,283 +6,251 @@
|
|||
|
||||
@section('content')
|
||||
<div class="content">
|
||||
<form method="POST" action="{{ route('admin.catalog-rule.store') }}" @submit.prevent="onSubmit">
|
||||
@csrf
|
||||
|
||||
<div class="page-header">
|
||||
<div class="page-title">
|
||||
<h1>
|
||||
<i class="icon angle-left-icon back-link" onclick="history.length > 1 ? history.go(-1) : window.location = '{{ url('/admin/dashboard') }}';"></i>
|
||||
|
||||
{{ __('admin::app.promotion.add-catalog-rule') }}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="page-action">
|
||||
<button type="submit" class="btn btn-lg btn-primary">
|
||||
{{ __('admin::app.promotion.save-btn-title') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="page-content">
|
||||
<div class="form-container">
|
||||
<catalog-rule></catalog-rule>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<catalog-rule></catalog-rule>
|
||||
</div>
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/x-template" id="catalog-rule-form-template">
|
||||
<div>
|
||||
@csrf()
|
||||
<form method="POST" action="{{ route('admin.catalog-rule.store') }}" @submit.prevent="onSubmit">
|
||||
@csrf
|
||||
|
||||
<accordian :active="true" title="Information">
|
||||
<div slot="body">
|
||||
<div class="control-group" :class="[errors.has('name') ? 'has-error' : '']">
|
||||
<label for="name" class="required">{{ __('admin::app.promotion.general-info.name') }}</label>
|
||||
<div class="page-header">
|
||||
<div class="page-title">
|
||||
<h1>
|
||||
<i class="icon angle-left-icon back-link" onclick="history.length > 1 ? history.go(-1) : window.location = '{{ url('/admin/dashboard') }}';"></i>
|
||||
|
||||
<input type="text" class="control" name="name" v-model="name" v-validate="'required'" value="{{ old('name') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.name') }}"">
|
||||
|
||||
<span class="control-error" v-if="errors.has('name')">@{{ errors.first('name') }}</span>
|
||||
{{ __('admin::app.promotion.add-catalog-rule') }}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('description') ? 'has-error' : '']">
|
||||
<label for="description">{{ __('admin::app.promotion.general-info.description') }}</label>
|
||||
|
||||
<textarea class="control" name="description" v-model="description" v-validate="'required'" value="{{ old('description') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.description') }}""></textarea>
|
||||
|
||||
<span class="control-error" v-if="errors.has('description')">@{{ errors.first('description') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('customer_groups[]') ? 'has-error' : '']">
|
||||
<label for="customer_groups" class="required">{{ __('admin::app.promotion.general-info.cust-groups') }}</label>
|
||||
|
||||
<select type="text" class="control" name="customer_groups[]" v-model="customer_groups" v-validate="'required'" data-vv-as=""{{ __('admin::app.promotion.general-info.cust-groups') }}"" multiple="multiple">
|
||||
<option disabled="disabled">Select Customer Groups</option>
|
||||
@foreach(app('Webkul\Customer\Repositories\CustomerGroupRepository')->all() as $channel)
|
||||
<option value="{{ $channel->id }}">{{ $channel->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
<span class="control-error" v-if="errors.has('customer_groups[]')">@{{ errors.first('customer_groups[]') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('channels[]') ? 'has-error' : '']">
|
||||
<label for="channels" class="required">{{ __('admin::app.promotion.general-info.channels') }}</label>
|
||||
|
||||
<select type="text" class="control" name="channels[]" v-model="channels" v-validate="'required'" data-vv-as=""{{ __('admin::app.promotion.general-info.channels') }}"" multiple="multiple">
|
||||
<option disabled="disabled">Select Channels</option>
|
||||
@foreach(app('Webkul\Core\Repositories\ChannelRepository')->all() as $channel)
|
||||
<option value="{{ $channel->id }}">{{ $channel->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
<span class="control-error" v-if="errors.has('channels[]')">@{{ errors.first('channels[]') }}</span>
|
||||
</div>
|
||||
|
||||
<datetime :name="starts_from">
|
||||
<div class="control-group" :class="[errors.has('starts_from') ? 'has-error' : '']">
|
||||
<label for="starts_from" class="required">{{ __('admin::app.promotion.general-info.starts-from') }}</label>
|
||||
|
||||
<input type="text" class="control" v-model="starts_from" name="starts_from" v-validate="'required'" data-vv-as=""{{ __('admin::app.promotion.general-info.starts-from') }}"">
|
||||
|
||||
<span class="control-error" v-if="errors.has('starts_from')">@{{ errors.first('starts_from') }}</span>
|
||||
</div>
|
||||
</datetime>
|
||||
|
||||
<datetime :name="starts_from">
|
||||
<div class="control-group" :class="[errors.has('ends_till') ? 'has-error' : '']">
|
||||
<label for="ends_till" class="required">{{ __('admin::app.promotion.general-info.ends-till') }}</label>
|
||||
|
||||
<input type="text" class="control" v-model="ends_till" name="ends_till" v-validate="'required'" data-vv-as=""{{ __('admin::app.promotion.general-info.ends-till') }}"">
|
||||
|
||||
<span class="control-error" v-if="errors.has('ends_till')">@{{ errors.first('ends_till') }}</span>
|
||||
</div>
|
||||
</datetime>
|
||||
|
||||
<div class="control-group" :class="[errors.has('priority') ? 'has-error' : '']">
|
||||
<label for="priority" class="required">{{ __('admin::app.promotion.general-info.priority') }}</label>
|
||||
|
||||
<input type="number" class="control" step="1" name="priority" v-model="priority" v-validate="'required|numeric|min_value:1'" value="{{ old('priority') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.priority') }}"">
|
||||
|
||||
<span class="control-error" v-if="errors.has('priority')">@{{ errors.first('priority') }}</span>
|
||||
<div class="page-action">
|
||||
<button type="submit" class="btn btn-lg btn-primary">
|
||||
{{ __('admin::app.promotion.save-btn-title') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</accordian>
|
||||
|
||||
<accordian :active="true" title="Conditions">
|
||||
<div slot="body">
|
||||
<div class="add-condition">
|
||||
<div class="control-group" :class="[errors.has('criteria') ? 'has-error' : '']">
|
||||
<label for="criteria" class="required">{{ __('admin::app.promotion.general-info.add-condition') }}</label>
|
||||
<div class="page-content">
|
||||
<div class="form-container">
|
||||
@csrf()
|
||||
|
||||
<select type="text" class="control" name="criteria" v-model="criteria" v-validate="'required'" value="" data-vv-as=""{{ __('admin::app.promotion.general-info.cust-groups') }}"">
|
||||
<option value="condition_combination">Condition Combination</option>
|
||||
<option value="attribute">Attribute</option>
|
||||
{{-- <option value="category">Category</option> --}}
|
||||
</select>
|
||||
<accordian :active="true" title="Information">
|
||||
<div slot="body">
|
||||
<div class="control-group" :class="[errors.has('name') ? 'has-error' : '']">
|
||||
<label for="name" class="required">{{ __('admin::app.promotion.general-info.name') }}</label>
|
||||
|
||||
<span class="control-error" v-if="errors.has('criteria')">@{{ errors.first('criteria') }}</span>
|
||||
</div>
|
||||
<input type="text" class="control" name="name" v-model="name" v-validate="'required'" value="{{ old('name') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.name') }}"">
|
||||
|
||||
<span class="btn btn-primary btn-lg" v-on:click="addCondition">Add Condition</span>
|
||||
</div>
|
||||
|
||||
<div class="condition-set" v-if="attributes_list.length">
|
||||
<!-- <span class="label mt-20">Assume all conditions are true:</span>
|
||||
<span class="label mt-20">Assume
|
||||
<select>
|
||||
<option>All</option>
|
||||
<option>Any</option>
|
||||
</select>
|
||||
are
|
||||
<select>
|
||||
<option>True</option>
|
||||
<option>False</option>
|
||||
</select>
|
||||
.
|
||||
</span> -->
|
||||
|
||||
<!-- Attribute -->
|
||||
<div v-for="(attrs, index) in attributes_list" :key="index">
|
||||
<div class="control-container mt-20">
|
||||
<div class="title-bar">
|
||||
<span>Attribute is </span>
|
||||
<span class="icon cross-icon" v-on:click="removeAttr(index)"></span>
|
||||
<span class="control-error" v-if="errors.has('name')">@{{ errors.first('name') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group mt-10" :key="index">
|
||||
<select class="control" name="attributes[]" v-model="attributes_list[index].attribute" v-validate="'required'" title="You Can Make Multiple Selections Here" style="margin-right: 15px;" v-on:change="enableCondition($event, index)">
|
||||
<option disabled="disabled">Select attribute</option>
|
||||
<option v-for="attr_ip in attrs_input" :value="attr_ip.id">@{{ attr_ip.name }}</option>
|
||||
<div class="control-group" :class="[errors.has('description') ? 'has-error' : '']">
|
||||
<label for="description">{{ __('admin::app.promotion.general-info.description') }}</label>
|
||||
|
||||
<textarea class="control" name="description" v-model="description" v-validate="'required'" value="{{ old('description') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.description') }}""></textarea>
|
||||
|
||||
<span class="control-error" v-if="errors.has('description')">@{{ errors.first('description') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('customer_groups[]') ? 'has-error' : '']">
|
||||
<label for="customer_groups" class="required">{{ __('admin::app.promotion.general-info.cust-groups') }}</label>
|
||||
|
||||
<select type="text" class="control" name="customer_groups[]" v-model="customer_groups" v-validate="'required'" data-vv-as=""{{ __('admin::app.promotion.general-info.cust-groups') }}"" multiple="multiple">
|
||||
<option disabled="disabled">Select Customer Groups</option>
|
||||
@foreach(app('Webkul\Customer\Repositories\CustomerGroupRepository')->all() as $channel)
|
||||
<option value="{{ $channel->id }}">{{ $channel->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
<div v-if='attributes_list[index].type == "text" || attributes_list[index].type == "textarea"'>
|
||||
<select class="control" name="attributes[]" v-model="attributes_list[index].condition" v-validate="'required'" style="margin-right: 15px;">
|
||||
<option>is</option>
|
||||
<option>is any of</option>
|
||||
<option>contains</option>
|
||||
</select>
|
||||
<span class="control-error" v-if="errors.has('customer_groups[]')">@{{ errors.first('customer_groups[]') }}</span>
|
||||
</div>
|
||||
|
||||
<input type="text" class="control" name="attributes[]" v-model="attributes_list[index].value" placeholder="Enter Value">
|
||||
<div class="control-group" :class="[errors.has('channels[]') ? 'has-error' : '']">
|
||||
<label for="channels" class="required">{{ __('admin::app.promotion.general-info.channels') }}</label>
|
||||
|
||||
<select type="text" class="control" name="channels[]" v-model="channels" v-validate="'required'" data-vv-as=""{{ __('admin::app.promotion.general-info.channels') }}"" multiple="multiple">
|
||||
<option disabled="disabled">Select Channels</option>
|
||||
@foreach(app('Webkul\Core\Repositories\ChannelRepository')->all() as $channel)
|
||||
<option value="{{ $channel->id }}">{{ $channel->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
<span class="control-error" v-if="errors.has('channels[]')">@{{ errors.first('channels[]') }}</span>
|
||||
</div>
|
||||
|
||||
<datetime :name="starts_from">
|
||||
<div class="control-group" :class="[errors.has('starts_from') ? 'has-error' : '']">
|
||||
<label for="starts_from" class="required">{{ __('admin::app.promotion.general-info.starts-from') }}</label>
|
||||
|
||||
<input type="text" class="control" v-model="starts_from" name="starts_from" v-validate="'required'" data-vv-as=""{{ __('admin::app.promotion.general-info.starts-from') }}"">
|
||||
|
||||
<span class="control-error" v-if="errors.has('starts_from')">@{{ errors.first('starts_from') }}</span>
|
||||
</div>
|
||||
</datetime>
|
||||
|
||||
<div v-if='attributes_list[index].type == "price"'>
|
||||
<select class="control" name="attributes[]" v-model="attributes_list[index].condition" v-validate="'required'" style="margin-right: 15px;">
|
||||
<option>is</option>
|
||||
<option>is any of</option>
|
||||
<option>contains</option>
|
||||
</select>
|
||||
<datetime :name="starts_from">
|
||||
<div class="control-group" :class="[errors.has('ends_till') ? 'has-error' : '']">
|
||||
<label for="ends_till" class="required">{{ __('admin::app.promotion.general-info.ends-till') }}</label>
|
||||
|
||||
<input type="number" step="0.1000" class="control" name="attributes[]" v-model="attributes_list[index].value" placeholder="Enter Value">
|
||||
<input type="text" class="control" v-model="ends_till" name="ends_till" v-validate="'required'" data-vv-as=""{{ __('admin::app.promotion.general-info.ends-till') }}"">
|
||||
|
||||
<span class="control-error" v-if="errors.has('ends_till')">@{{ errors.first('ends_till') }}</span>
|
||||
</div>
|
||||
</datetime>
|
||||
|
||||
<div v-else-if='attributes_list[index].type == "boolean"'>
|
||||
<select class="control" name="attributes[]" v-model="attributes_list[index].condition" v-validate="'required'" style="margin-right: 15px;">
|
||||
<option selected="selected">is</option>
|
||||
</select>
|
||||
<div class="control-group" :class="[errors.has('priority') ? 'has-error' : '']">
|
||||
<label for="priority" class="required">{{ __('admin::app.promotion.general-info.priority') }}</label>
|
||||
|
||||
<select class="control" name="attributes[]" v-model="attributes_list[index].value">
|
||||
<option value="1">Yes</option>
|
||||
<option value="0">No</option>
|
||||
</select>
|
||||
</div>
|
||||
<input type="number" class="control" step="1" name="priority" v-model="priority" v-validate="'required|numeric|min_value:1'" value="{{ old('priority') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.priority') }}"">
|
||||
|
||||
<div v-else-if='attributes_list[index].type == "date"'>
|
||||
<select class="control" name="attributes[]" v-model="attributes_list[index].condition" v-validate="'required'" style="margin-right: 15px;">
|
||||
<option :selected="true">is</option>
|
||||
</select>
|
||||
|
||||
<date>
|
||||
<input type="text" class="control" v-model="attributes_list[index].value" name="attributes[]" v-validate="'required'" value="Enter Value">
|
||||
</date>
|
||||
</div>
|
||||
|
||||
<div v-else-if='attributes_list[index].type == "datetime"'>
|
||||
<select class="control" name="attributes[]" v-model="attributes_list[index].condition" v-validate="'required'" style="margin-right: 15px;">
|
||||
<option selected="selected">is</option>
|
||||
</select>
|
||||
|
||||
<datetime>
|
||||
<input type="text" class="control" v-model="attributes_list[index].value" name="attributes[]" v-validate="'required'" value="Enter Value">
|
||||
</datetime>
|
||||
</div>
|
||||
|
||||
<div v-else-if='attributes_list[index].type == "select" || attributes_list[index].type == "multiselect"'>
|
||||
<select class="control" name="attributes[]" v-model="attributes_list[index].condition" v-validate="'required'" style="margin-right: 15px;">
|
||||
<option selected="selected">is</option>
|
||||
</select>
|
||||
|
||||
<datetime>
|
||||
<input type="text" class="control" v-model="attributes_list[index].value" name="attributes[]" v-validate="'required'" value="Enter Select Values">
|
||||
</datetime>
|
||||
</div>
|
||||
<span class="control-error" v-if="errors.has('priority')">@{{ errors.first('priority') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</accordian>
|
||||
|
||||
<!-- category -->
|
||||
<div v-for="(cat, index) in cats">
|
||||
<div class="control-container mt-20">
|
||||
<div class="title-bar">
|
||||
<span>Category </span>
|
||||
<span class="icon cross-icon" v-on:click="removeCat(index)"></span>
|
||||
<accordian :active="true" title="Conditions">
|
||||
<div slot="body">
|
||||
<div class="add-condition">
|
||||
<div class="control-group" :class="[errors.has('criteria') ? 'has-error' : '']">
|
||||
<label for="criteria" class="required">{{ __('admin::app.promotion.general-info.add-condition') }}</label>
|
||||
|
||||
<select type="text" class="control" name="criteria" v-model="criteria" v-validate="'required'" value="" data-vv-as=""{{ __('admin::app.promotion.general-info.cust-groups') }}"">
|
||||
<option value="condition_combination">Condition Combination</option>
|
||||
<option value="attribute">Attribute</option>
|
||||
</select>
|
||||
|
||||
<span class="control-error" v-if="errors.has('criteria')">@{{ errors.first('criteria') }}</span>
|
||||
</div>
|
||||
|
||||
<span class="btn btn-primary btn-lg" v-on:click="addCondition">Add Condition</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group mt-15" :key="index">
|
||||
<select class="control" name="categories[]" v-model="cats[index].condition" v-validate="'required'" title="You Can Make Multiple Selections Here" style="margin-right: 15px;">
|
||||
<option>is</option>
|
||||
<option>is any of</option>
|
||||
<option>contains</option>
|
||||
</select>
|
||||
<div class="condition-set" v-if="attributes_list.length">
|
||||
<!-- Attribute -->
|
||||
<div v-for="(attrs, index) in attributes_list" :key="index">
|
||||
<div class="control-container mt-20">
|
||||
<div class="title-bar">
|
||||
<span>Attribute is </span>
|
||||
<span class="icon cross-icon" v-on:click="removeAttr(index)"></span>
|
||||
</div>
|
||||
|
||||
<select class="control" name="categories[]" v-model="cats[index].category" v-validate="'required'" value="{{ old('category') }}" data-vv-as=""{{ __('admin::app.promotion.category') }}"" multiple>
|
||||
<option disabled="disabled">Select Category</option>
|
||||
<option v-for="category in categories" :value="category.id">@{{ category.name }}</option>
|
||||
</select>
|
||||
<div class="control-group mt-10" :key="index">
|
||||
<select class="control" name="attributes[]" v-model="attributes_list[index].attribute" v-validate="'required'" title="You Can Make Multiple Selections Here" style="margin-right: 15px;" v-on:change="enableCondition($event, index)">
|
||||
<option disabled="disabled">Select attribute</option>
|
||||
<option v-for="attr_ip in attrs_input" :value="attr_ip.id">@{{ attr_ip.name }}</option>
|
||||
</select>
|
||||
|
||||
<div v-if='attributes_list[index].type == "text" || attributes_list[index].type == "textarea"'>
|
||||
<select class="control" name="attributes[]" v-model="attributes_list[index].condition" v-validate="'required'" style="margin-right: 15px;">
|
||||
@foreach($criteria[4]['text'] as $key => $value)
|
||||
<option value="{{ $key }}">{{ __($value) }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
<input type="text" class="control" name="attributes[]" v-model="attributes_list[index].value" placeholder="Enter Value">
|
||||
</div>
|
||||
|
||||
<div v-if='attributes_list[index].type == "price"'>
|
||||
<select class="control" name="attributes[]" v-model="attributes_list[index].condition" v-validate="'required'" style="margin-right: 15px;">
|
||||
@foreach($criteria[4]['numeric'] as $key => $value)
|
||||
<option value="{{ $key }}">{{ __($value) }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
<input type="number" step="0.1000" class="control" name="attributes[]" v-model="attributes_list[index].value" placeholder="Enter Value">
|
||||
</div>
|
||||
|
||||
<div v-else-if='attributes_list[index].type == "boolean"'>
|
||||
<select class="control" name="attributes[]" v-model="attributes_list[index].condition" v-validate="'required'" style="margin-right: 15px;">
|
||||
<option selected="selected">is</option>
|
||||
</select>
|
||||
|
||||
<select class="control" name="attributes[]" v-model="attributes_list[index].value">
|
||||
@foreach($criteria[4]['boolean'] as $key => $value)
|
||||
<option value="{{ $key }}">{{ __($value) }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div v-else-if='attributes_list[index].type == "date"'>
|
||||
<select class="control" name="attributes[]" v-model="attributes_list[index].condition" v-validate="'required'" style="margin-right: 15px;">
|
||||
@foreach($criteria[4]['numeric'] as $key => $value)
|
||||
<option value="{{ $key }}">{{ __($value) }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
<date>
|
||||
<input type="text" class="control" v-model="attributes_list[index].value" name="attributes[]" v-validate="'required'" value="Enter Value">
|
||||
</date>
|
||||
</div>
|
||||
|
||||
<div v-else-if='attributes_list[index].type == "datetime"'>
|
||||
<select class="control" name="attributes[]" v-model="attributes_list[index].condition" v-validate="'required'" style="margin-right: 15px;">
|
||||
@foreach($criteria[4]['numeric'] as $key => $value)
|
||||
<option value="{{ $key }}">{{ __($value) }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
<datetime>
|
||||
<input type="text" class="control" v-model="attributes_list[index].value" name="attributes[]" v-validate="'required'" value="Enter Value">
|
||||
</datetime>
|
||||
</div>
|
||||
|
||||
<div v-else-if='attributes_list[index].type == "select" || attributes_list[index].type == "multiselect"'>
|
||||
<select class="control" name="attributes[]" v-model="attributes_list[index].condition" v-validate="'required'" style="margin-right: 15px;">
|
||||
@foreach($criteria[4]['text'] as $key => $value)
|
||||
<option value="{{ $key }}">{{ __($value) }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
<select class="control" v-model="attributes_list[index].value" name="attributes[]" v-validate="'required'" multiple>
|
||||
<option v-for="option in attributes_list[index].options" :value="option.id">@{{ option.admin_name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="all_conditions[]" v-model="all_conditions">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</accordian>
|
||||
|
||||
<input type="hidden" name="all_conditions[]" v-model="all_conditions">
|
||||
<accordian :active="true" title="Actions">
|
||||
<div slot="body">
|
||||
<div class="control-group" :class="[errors.has('apply') ? 'has-error' : '']">
|
||||
<label for="apply" class="required">Apply</label>
|
||||
|
||||
<select class="control" name="apply" v-model="apply" v-validate="'required'" value="{{ old('apply') }}" data-vv-as=""Apply As"" v-on:change="detectApply">
|
||||
@foreach($criteria[3]['actions'] as $key => $value)
|
||||
<option value="{{ $key }}">{{ __($value) }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
<span class="control-error" v-if="errors.has('apply')">@{{ errors.first('apply') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('disc_amount') ? 'has-error' : '']" v-if="apply_amt">
|
||||
<label for="disc_amount" class="required">{{ __('admin::app.promotion.general-info.disc_amt') }}</label>
|
||||
|
||||
<input type="number" step="1.0000" class="control" name="disc_amount" v-model="disc_amount" v-validate="'required|decimal|min_value:0.0001'" value="{{ old('disc_amount') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.disc_amt') }}"">
|
||||
|
||||
<span class="control-error" v-if="errors.has('disc_amount')">@{{ errors.first('disc_amount') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('disc_percent') ? 'has-error' : '']" v-if="apply_prct">
|
||||
<label for="disc_percent" class="required">{{ __('admin::app.promotion.general-info.disc_percent') }}</label>
|
||||
|
||||
<input type="number" step="0.5000" class="control" name="disc_percent" v-model="disc_percent" v-validate="'required|decimal|min_value:0.0001'" value="{{ old('disc_percent') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.disc_percent') }}"">
|
||||
|
||||
<span class="control-error" v-if="errors.has('disc_percent')">@{{ errors.first('disc_percent') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</accordian>
|
||||
</div>
|
||||
</div>
|
||||
</accordian>
|
||||
|
||||
<accordian :active="true" title="Actions">
|
||||
<div slot="body">
|
||||
<div class="control-group" :class="[errors.has('apply') ? 'has-error' : '']">
|
||||
<label for="apply" class="required">Apply</label>
|
||||
|
||||
<select class="control" name="apply" v-model="apply" v-validate="'required'" value="{{ old('apply') }}" data-vv-as=""Apply As"" v-on:change="detectApply">
|
||||
<option value="1">{{ __('admin::app.promotion.catalog.apply-percent') }}</option>
|
||||
<option value="2">{{ __('admin::app.promotion.catalog.apply-fixed') }}</option>
|
||||
<option value="3">{{ __('admin::app.promotion.catalog.adjust-to-percent') }}</option>
|
||||
<option value="4">{{ __('admin::app.promotion.catalog.adjust-to-value') }}</option>
|
||||
</select>
|
||||
|
||||
<span class="control-error" v-if="errors.has('apply')">@{{ errors.first('apply') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('disc_amount') ? 'has-error' : '']" v-if="apply_amt">
|
||||
<label for="disc_amount" class="required">{{ __('admin::app.promotion.general-info.disc_amt') }}</label>
|
||||
|
||||
<input type="number" step="1.0000" class="control" name="disc_amount" v-model="disc_amount" v-validate="'required|decimal|min_value:0.0001'" value="{{ old('disc_amount') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.disc_amt') }}"">
|
||||
|
||||
<span class="control-error" v-if="errors.has('disc_amount')">@{{ errors.first('disc_amount') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('disc_percent') ? 'has-error' : '']" v-if="apply_prct">
|
||||
<label for="disc_percent" class="required">{{ __('admin::app.promotion.general-info.disc_percent') }}</label>
|
||||
|
||||
<input type="number" step="0.5000" class="control" name="disc_percent" v-model="disc_percent" v-validate="'required|decimal|min_value:0.0001'" value="{{ old('disc_percent') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.disc_percent') }}"">
|
||||
|
||||
<span class="control-error" v-if="errors.has('disc_percent')">@{{ errors.first('disc_percent') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</accordian>
|
||||
</form>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
|
@ -297,8 +265,10 @@
|
|||
apply: null,
|
||||
apply_amt: false,
|
||||
apply_prct: false,
|
||||
applied_config: @json($criteria[3]),
|
||||
attributes_list: [],
|
||||
attrs_input: @json($criteria[0]),
|
||||
attrs_options: @json($criteria[2]),
|
||||
attr_object: {
|
||||
attribute: null,
|
||||
condition: null,
|
||||
|
|
@ -331,6 +301,7 @@
|
|||
},
|
||||
|
||||
mounted () {
|
||||
console.log(this.attrs_options);
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
|
@ -370,25 +341,19 @@
|
|||
var this_this = this;
|
||||
|
||||
if (this.attrs_input[event.target.selectedIndex - 1].type == 'select' || this.attrs_input[event.target.selectedIndex - 1].type == 'multiselect') {
|
||||
axios.post('{{ route('admin.catalog-rule.options') }}', {
|
||||
'attribute' : this.attrs_input[event.target.selectedIndex - 1].attribute
|
||||
})
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
console.log(this.attrs_input[event.target.selectedIndex - 1].name);
|
||||
|
||||
this.attributes_list[index].value = null;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
this.attributes_list[index].options = this.attrs_options[this.attrs_input[event.target.selectedIndex - 1].name];
|
||||
|
||||
this.attributes_list[index].value = [];
|
||||
}
|
||||
},
|
||||
|
||||
detectApply() {
|
||||
if (this.apply == 1 || this.apply == 3) {
|
||||
if (this.apply == 0 || this.apply == 2) {
|
||||
this.apply_prct = true;
|
||||
this.apply_amt = false;
|
||||
} else if (this.apply == 2 || this.apply == 4) {
|
||||
} else if (this.apply == 1 || this.apply == 3) {
|
||||
this.apply_prct = false;
|
||||
this.apply_amt = true;
|
||||
}
|
||||
|
|
@ -402,8 +367,38 @@
|
|||
this.cats.splice(index, 1);
|
||||
},
|
||||
|
||||
beforeOnSubmit() {
|
||||
onSubmit: function (e) {
|
||||
for (index in this.attributes_list) {
|
||||
if (this.attributes_list[index].condition == null || this.attributes_list[index].condition == "" || this.attributes_list[index].condition == undefined) {
|
||||
window.flashMessages = [{'type': 'alert-error', 'message': "{{ __('admin::app.promotion.catalog.condition-missing') }}" }];
|
||||
|
||||
this.$root.addFlashMessages();
|
||||
|
||||
return false;
|
||||
} else if (this.attributes_list[index].value == null || this.attributes_list[index].value == "" || this.attributes_list[index].value == undefined) {
|
||||
window.flashMessages = [{'type': 'alert-error', 'message': "{{ __('admin::app.promotion.catalog.condition-missing') }}" }];
|
||||
|
||||
this.$root.addFlashMessages();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
this.all_conditions = JSON.stringify(this.attributes_list);
|
||||
|
||||
this.$validator.validateAll().then(result => {
|
||||
if (result) {
|
||||
e.target.submit();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
addFlashMessages() {
|
||||
const flashes = this.$refs.flashes;
|
||||
|
||||
flashMessages.forEach(function(flash) {
|
||||
flashes.addFlash(flash);
|
||||
}, this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,58 +0,0 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'catalog' => [
|
||||
0 => 'Apply as percentage',
|
||||
1 => 'Apply as fixed amount',
|
||||
2 => 'Adjust to percentage',
|
||||
3 => 'Adjust to discount value'
|
||||
],
|
||||
|
||||
'cart' => [
|
||||
0 => [
|
||||
'name' => 'Sub-total',
|
||||
'type' => 'numeric'
|
||||
],
|
||||
1 => [
|
||||
'name' => 'Total Items Quantity',
|
||||
'type' => 'numeric'
|
||||
],
|
||||
2 => [
|
||||
'name' => 'Total Weight',
|
||||
'type' => 'numeric'
|
||||
],
|
||||
3 => [
|
||||
'name' => 'Payment Method',
|
||||
'type' => 'string'
|
||||
],
|
||||
4 => [
|
||||
'name' => 'Shipping Postcode',
|
||||
'type' => 'string'
|
||||
],
|
||||
5 => [
|
||||
'name' => 'Shipping State',
|
||||
'type' => 'string'
|
||||
],
|
||||
6 => [
|
||||
'name' => 'Shipping Country',
|
||||
'type' => 'string'
|
||||
]
|
||||
],
|
||||
|
||||
'conditions' => [
|
||||
'numeric' => [
|
||||
0 => 'Equals',
|
||||
1 => 'Equals or greater',
|
||||
2 => 'Equals or lesser',
|
||||
3 => 'Greater than',
|
||||
4 => 'Lesser than'
|
||||
],
|
||||
|
||||
'text' => [
|
||||
0 => 'is',
|
||||
1 => 'is not',
|
||||
2 => 'contains',
|
||||
3 => 'does not contains'
|
||||
],
|
||||
]
|
||||
];
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'conditions' => [
|
||||
'numeric' => [
|
||||
0 => 'Equals',
|
||||
1 => 'Equals or greater',
|
||||
2 => 'Equals or lesser',
|
||||
3 => 'Greater than',
|
||||
4 => 'Lesser than'
|
||||
],
|
||||
|
||||
'text' => [
|
||||
0 => 'is',
|
||||
1 => 'is not',
|
||||
2 => 'contains',
|
||||
3 => 'does not contains'
|
||||
],
|
||||
|
||||
'boolean' => [
|
||||
0 => 'True/Yes',
|
||||
1 => 'False/No',
|
||||
]
|
||||
],
|
||||
|
||||
'catalog' => [
|
||||
'actions' => [
|
||||
0 => 'admin::app.promotion.catalog.apply-percent',
|
||||
1 => 'admin::app.promotion.catalog.apply-fixed',
|
||||
2 => 'admin::app.promotion.catalog.adjust-to-percent',
|
||||
3 => 'admin::app.promotion.catalog.adjust-to-value'
|
||||
],
|
||||
|
||||
'attributes' => [
|
||||
0 => [
|
||||
'name' => 'Sub-total',
|
||||
'type' => 'numeric'
|
||||
],
|
||||
1 => [
|
||||
'name' => 'Total Items Quantity',
|
||||
'type' => 'numeric'
|
||||
],
|
||||
2 => [
|
||||
'name' => 'Total Weight',
|
||||
'type' => 'numeric'
|
||||
],
|
||||
3 => [
|
||||
'name' => 'Payment Method',
|
||||
'type' => 'string'
|
||||
],
|
||||
4 => [
|
||||
'name' => 'Shipping Postcode',
|
||||
'type' => 'string'
|
||||
],
|
||||
5 => [
|
||||
'name' => 'Shipping State',
|
||||
'type' => 'string'
|
||||
],
|
||||
6 => [
|
||||
'name' => 'Shipping Country',
|
||||
'type' => 'string'
|
||||
]
|
||||
]
|
||||
],
|
||||
|
||||
'cart' => [
|
||||
'actions' => [
|
||||
0 => 'Apply as percentage',
|
||||
1 => 'Apply as fixed amount',
|
||||
2 => 'Adjust to percentage',
|
||||
3 => 'Adjust to discount value'
|
||||
],
|
||||
|
||||
'attributes' => [
|
||||
0 => [
|
||||
'name' => 'Sub-total',
|
||||
'type' => 'numeric'
|
||||
],
|
||||
1 => [
|
||||
'name' => 'Total Items Quantity',
|
||||
'type' => 'numeric'
|
||||
],
|
||||
2 => [
|
||||
'name' => 'Total Weight',
|
||||
'type' => 'numeric'
|
||||
],
|
||||
3 => [
|
||||
'name' => 'Payment Method',
|
||||
'type' => 'string'
|
||||
],
|
||||
4 => [
|
||||
'name' => 'Shipping Postcode',
|
||||
'type' => 'string'
|
||||
],
|
||||
5 => [
|
||||
'name' => 'Shipping State',
|
||||
'type' => 'string'
|
||||
],
|
||||
6 => [
|
||||
'name' => 'Shipping Country',
|
||||
'type' => 'string'
|
||||
]
|
||||
]
|
||||
],
|
||||
];
|
||||
|
|
@ -26,12 +26,14 @@ class CreateCatalogRulesTable extends Migration
|
|||
$table->datetime('starts_from')->nullable();
|
||||
$table->datetime('ends_till')->nullable();
|
||||
$table->boolean('status')->default(1);
|
||||
$table->integer('priority')->unsigned();
|
||||
$table->json('conditions')->nullable();
|
||||
$table->json('actions')->nullable();
|
||||
$table->boolean('end_other_rules')->default(1);
|
||||
$table->integer('sort_order')->unsigned()->default(0);
|
||||
$table->string('action_type')->nullable();
|
||||
$table->decimal('discount_amount', 12, 4)->default(0.0000);
|
||||
$table->decimal('dis_amt', 12, 4)->default(0.0000);
|
||||
$table->decimal('dis_qty', 12, 4)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Schema;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateCatalogProductsTable extends Migration
|
||||
class CreateCatalogRuleProductsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
|
|
@ -13,7 +13,7 @@ class CreateCatalogProductsTable extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('catalog_products', function (Blueprint $table) {
|
||||
Schema::create('catalog_rule_products', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('catalog_rule_id')->unsigned()->unique();
|
||||
$table->foreign('catalog_rule_id')->references('id')->on('catalog_rules')->onDelete('cascade');
|
||||
|
|
@ -21,6 +21,7 @@ class CreateCartRuleTable extends Migration
|
|||
$table->datetime('ends_till')->nullable();
|
||||
$table->json('conditions')->nullable();
|
||||
$table->json('actions')->nullable();
|
||||
$table->integer('priority')->unsigned()->default(0);
|
||||
$table->longtext('product_ids')->nullable();
|
||||
$table->boolean('status')->default(1);
|
||||
$table->boolean('end_other_rules')->default(1);
|
||||
|
|
|
|||
|
|
@ -70,12 +70,7 @@ class CartRuleController extends Controller
|
|||
$this->product = $product;
|
||||
$this->CartRule = $cartRule;
|
||||
$this->cart = $cart;
|
||||
$this->appliedConfig = [
|
||||
0 => trans('admin::app.promotion.Cart.apply-percent'),
|
||||
1 => trans('admin::app.promotion.Cart.apply-fixed'),
|
||||
2 => trans('admin::app.promotion.Cart.adjust-to-percent'),
|
||||
3 => trans('admin::app.promotion.Cart.adjust-to-value')
|
||||
];
|
||||
$this->appliedConfig = config('pricerules.catalog');
|
||||
}
|
||||
|
||||
public function index()
|
||||
|
|
@ -85,7 +80,7 @@ class CartRuleController extends Controller
|
|||
|
||||
public function create()
|
||||
{
|
||||
return view($this->_config['view'])->with('criteria', [config('pricerules'), $this->fetchOptionableAttributes(), $this->getStatesAndCountries()]);
|
||||
return view($this->_config['view'])->with('criteria', [$this->appliedConfig, $this->fetchOptionableAttributes(), $this->getStatesAndCountries()]);
|
||||
}
|
||||
|
||||
public function store()
|
||||
|
|
|
|||
|
|
@ -49,6 +49,11 @@ class CatalogRuleController extends Controller
|
|||
*/
|
||||
protected $appliedConfig;
|
||||
|
||||
/**
|
||||
* Property for catalog rule application
|
||||
*/
|
||||
protected $appliedConditions;
|
||||
|
||||
/**
|
||||
* To hold the catalog repository instance
|
||||
*/
|
||||
|
|
@ -62,6 +67,8 @@ class CatalogRuleController extends Controller
|
|||
$this->category = $category;
|
||||
$this->product = $product;
|
||||
$this->catalogRule = $catalogRule;
|
||||
$this->appliedConfig = config('pricerules.catalog');
|
||||
$this->appliedConditions = config('pricerules.conditions');
|
||||
}
|
||||
|
||||
public function index()
|
||||
|
|
@ -71,7 +78,7 @@ class CatalogRuleController extends Controller
|
|||
|
||||
public function create()
|
||||
{
|
||||
return view($this->_config['view'])->with('criteria', [$this->attribute->getPartial(), $this->category->getPartial()]);
|
||||
return view($this->_config['view'])->with('criteria', [$this->attribute->getPartial(), $this->category->getPartial(), $this->fetchOptionableAttributes(), $this->appliedConfig, $this->appliedConditions]);
|
||||
}
|
||||
|
||||
public function store()
|
||||
|
|
@ -87,15 +94,28 @@ class CatalogRuleController extends Controller
|
|||
'ends_till' => 'required|date',
|
||||
'priority' => 'required|numeric',
|
||||
'criteria' => 'required',
|
||||
'apply' => 'required|numeric|min:1|max:4'
|
||||
'all_conditions' => 'required|array',
|
||||
'apply' => 'required|numeric|min:0|max:3'
|
||||
]);
|
||||
|
||||
dd(request()->all());
|
||||
$catalogRule = $this->catalogRule->create(request()->all());
|
||||
$data = request()->all();
|
||||
$data['status'] = 1;
|
||||
|
||||
dd($data);
|
||||
|
||||
$catalogRule = $this->catalogRule->create($data);
|
||||
}
|
||||
|
||||
public function fetchAttributeOptions()
|
||||
public function fetchOptionableAttributes()
|
||||
{
|
||||
return [request()->all()];
|
||||
$attributesWithOptions = array();
|
||||
|
||||
foreach($this->attribute->all() as $attribute) {
|
||||
if (($attribute->type == 'select' || $attribute->type == 'multiselect') && $attribute->code != 'tax_category_id') {
|
||||
$attributesWithOptions[$attribute->admin_name] = $attribute->options->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
return $attributesWithOptions;
|
||||
}
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ class DiscountServiceProvider extends ServiceProvider
|
|||
protected function registerConfig()
|
||||
{
|
||||
$this->mergeConfigFrom(
|
||||
dirname(__DIR__) . '/Config/cart-attributes.php', 'pricerules'
|
||||
dirname(__DIR__) . '/Config/rule-conditions.php', 'pricerules'
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue