Cart rule labels bug fixed
This commit is contained in:
parent
db3b35ff4c
commit
3c95e11df7
|
|
@ -316,7 +316,7 @@
|
|||
</div>
|
||||
</accordian>
|
||||
|
||||
<accordian :active="false" title="Coupons" v-if="use_coupon">
|
||||
<accordian :active="false" title="Coupons" v-if="use_coupon == 1">
|
||||
<div slot="body">
|
||||
|
||||
{{-- <div v-if="!auto_generation">
|
||||
|
|
@ -366,7 +366,7 @@
|
|||
<div class="control-group" :class="[errors.has('label') ? 'has-error' : '']">
|
||||
<label for="code">{{ $locale->code }}</label>
|
||||
|
||||
<input type="text" class="control" name="label[{{ $channel->code }}][{{ $locale->code }}]" v-model="label.{{ $channel->code }}.{{ $locale->code }}" v-validate="'alpha'" data-vv-as=""Label"">
|
||||
<input type="text" class="control" name="label[{{ $channel->code }}][{{ $locale->code }}]" v-model="label.{{ $channel->code }}.{{ $locale->code }}" v-validate="'alpha_spaces'" data-vv-as=""Label"">
|
||||
|
||||
<span class="control-error" v-if="errors.has('label')">@{{ errors.first('label') }}</span>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@
|
|||
|
||||
<accordian :active="true" title="Information">
|
||||
<div slot="body">
|
||||
<input type="hidden" name="all_conditions" v-model="all_conditions">
|
||||
|
||||
<div class="control-group" :class="[errors.has('name') ? 'has-error' : '']">
|
||||
<label for="name" class="required">{{ __('admin::app.promotion.general-info.name') }}</label>
|
||||
|
||||
|
|
@ -232,9 +234,6 @@
|
|||
|
||||
<input type="number" step="0.1000" class="control" name="cart_attributes[]" v-model="conditions_list[index].value" placeholder="Enter Value">
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="all_conditions" v-model="all_conditions">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -352,7 +351,14 @@
|
|||
<accordian :active="false" title="labels">
|
||||
<div slot="body">
|
||||
@foreach($cart_rule[3]->labels as $label)
|
||||
<span>[{{ $label->channel->code }}]</span>
|
||||
<div class="control-group" :class="[errors.has('label') ? 'has-error' : '']">
|
||||
<label for="code">{{ $label->locale->code }}</label>
|
||||
|
||||
<input type="text" class="control" name="label[{{ $label->channel->code }}][{{ $label->locale->code }}]" value="{{ $label->label }}" v-validate="'required'" data-vv-as=""Label"">
|
||||
|
||||
<span class="control-error" v-if="errors.has('label')">@{{ errors.first('label') }}</span>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</accordian>
|
||||
|
|
@ -405,15 +411,14 @@
|
|||
dedicated_label: true,
|
||||
|
||||
global_label: null,
|
||||
label: {
|
||||
@foreach(core()->getAllChannels() as $channel)
|
||||
@foreach($channel->locales as $locale)
|
||||
{{ trim($channel->code) }} : {
|
||||
{{ trim($locale->code) }}: ''
|
||||
},
|
||||
@endforeach
|
||||
@endforeach
|
||||
},
|
||||
labels: [],
|
||||
// label: {
|
||||
// @foreach(core()->getAllChannels() as $channel)
|
||||
// @foreach($channel->locales as $locale)
|
||||
// {{ trim($channel->code) }} : null,
|
||||
// @endforeach
|
||||
// @endforeach
|
||||
// },
|
||||
|
||||
criteria: null,
|
||||
conditions: @json($cart_rule[0]).conditions,
|
||||
|
|
|
|||
|
|
@ -105,7 +105,6 @@ class CartRuleController extends Controller
|
|||
'channels' => 'required|array',
|
||||
'status' => 'required|boolean',
|
||||
'use_coupon' => 'boolean|required',
|
||||
// 'auto_generation' => 'boolean|sometimes',
|
||||
'usage_limit' => 'numeric|min:0',
|
||||
'per_customer' => 'numeric|min:0',
|
||||
'action_type' => 'required|string',
|
||||
|
|
@ -282,8 +281,6 @@ class CartRuleController extends Controller
|
|||
|
||||
$data = request()->all();
|
||||
|
||||
dd($data);
|
||||
|
||||
if ($data['starts_from'] == "" || $data['ends_till'] == "") {
|
||||
$data['starts_from'] = null;
|
||||
$data['ends_till'] = null;
|
||||
|
|
@ -362,20 +359,7 @@ class CartRuleController extends Controller
|
|||
$ruleGroupUpdated = $this->cartRule->CustomerGroupSync($customer_groups, $ruleUpdated);
|
||||
$ruleChannelUpdated = $this->cartRule->ChannelSync($channels, $ruleUpdated);
|
||||
|
||||
// if (isset($labels['global'])) {
|
||||
// foreach (core()->getAllChannels() as $channel) {
|
||||
// $label1['channel_id'] = $channel->id;
|
||||
// foreach ($channel->locales as $locale) {
|
||||
// $label1['locale_id'] = $locale->id;
|
||||
// $label1['label'] = $labels['global'];
|
||||
|
||||
// $ruleLabelUpdated = $this->cartRuleLabel->create($label1);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// $label2['label'] = $labels['global'];
|
||||
// $ruleLabelUpdated = $this->cartRuleLabel->create($label2);
|
||||
// }
|
||||
$labelsUpdated = $this->cartRule->LabelSync($labels, $ruleUpdated);
|
||||
|
||||
if (isset($coupons)) {
|
||||
$coupons['cart_rule_id'] = $ruleUpdated->id;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class CartRuleRepository extends Repository
|
|||
$this->cartRuleChannels = $cartRuleChannels;
|
||||
$this->cartRuleCustomerGroups = $cartRuleCustomerGroups;
|
||||
$this->cartRuleCoupons = $cartRuleCoupons;
|
||||
$this->cartRuleLabels = $cartRuleLabels;
|
||||
$this->cartRuleLabel = $cartRuleLabels;
|
||||
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
|
@ -146,15 +146,51 @@ class CartRuleRepository extends Repository
|
|||
/**
|
||||
* To sync the labels associated with the cart rule
|
||||
*/
|
||||
public function LabelsSync($labels, $cartRule)
|
||||
public function LabelSync($labels, $cartRule)
|
||||
{
|
||||
foreach ($labels as $channelCode => $value) {
|
||||
$localeCode = array_keys($value)[0];
|
||||
$localeValue = array_values($value)[0];
|
||||
|
||||
$updated = 0;
|
||||
foreach ($cartRule->labels as $label) {
|
||||
if ($label->channel->code == $channelCode && $label->locale->code == $localeCode) {
|
||||
$label->update([
|
||||
'label' => $localeValue
|
||||
]);
|
||||
|
||||
$updated = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($updated == 0) {
|
||||
foreach (core()->getAllChannels() as $channel) {
|
||||
if ($channel->code == $channelCode) {
|
||||
$newLabel['channel_id'] = $channel->id;
|
||||
}
|
||||
|
||||
foreach($channel->locales as $locale) {
|
||||
if ($localeCode == $locale->code) {
|
||||
$newLabel['locale_id'] = $locale->id;
|
||||
$newLabel['label'] = $localeValue;
|
||||
$newLabel['cart_rule_id'] = $cartRule->id;
|
||||
|
||||
$ruleLabelCreated = $this->CartRuleLabels->create($newLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$updated = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* To sync the coupons associated with the cart rule
|
||||
*/
|
||||
public function CouponsSync($coupon, $cartRule)
|
||||
public function CouponSync($coupon, $cartRule)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue