Merge pull request #1420 from prashant-webkul/development

Fixed translation issue in catalog rule delete notification
This commit is contained in:
Jitendra Singh 2019-09-09 13:16:02 +05:30 committed by GitHub
commit da8b21cab1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 138 additions and 130 deletions

View File

@ -1,6 +1,24 @@
<?php
return [
'save' => 'Save',
'create' => 'Create',
'update' => 'Update',
'delete' => 'Delete',
'failed' => 'Failed',
'store' => 'Store',
'image' => 'Image',
'no result' => 'No result',
'product' => 'Product',
'attribute' => 'Attribute',
'yes' => 'Yes',
'no' => 'No',
'true' => 'True',
'false' => 'False',
'apply' => 'Apply',
'action' => 'Action',
'label' => 'Label',
'common' => [
'no-result-found' => 'We could not find any records.',
'country' => 'Country',

View File

@ -16,7 +16,7 @@
<div class="page-action">
<button type="submi t" class="btn btn-lg btn-primary">
{{ __('admin::app.account.save-btn-title') }}
{{ __('admin::app.save') }}
</button>
</div>
</div>

View File

@ -20,7 +20,7 @@
<div class="page-action">
<button type="submit" class="btn btn-lg btn-primary">
{{ __('admin::app.catalog.categories.save-btn-title') }}
{{ __('admin::app.catalog.categories.-btn-title') }}
</button>
</div>
</div>

View File

@ -235,7 +235,7 @@
<accordian :active="false" title="{{ __('admin::app.promotion.actions') }}">
<div slot="body">
<div class="control-group" :class="[errors.has('action_type') ? 'has-error' : '']">
<label for="action_type" class="required">{{ __('admin::app.promotion.general-info.apply') }}</label>
<label for="action_type" class="required">{{ __('admin::app.action') }}</label>
<select class="control" name="action_type" v-model="action_type" v-validate="'required'" value="{{ old('action_type') }}" data-vv-as="&quot;{{ __('admin::app.promotion.general-info.apply') }}&quot;" v-on:change="detectApply">
<option v-for="(action, index) in actions" :value="index">@{{ action }}</option>
@ -402,7 +402,7 @@
@foreach(core()->getAllChannels() as $channel)
@foreach($channel->locales as $locale)
<div class="control-group" :class="[errors.has('label') ? 'has-error' : '']">
<label for="code"><span class="locale">[{{ $channel->code }} - {{ $locale->code }}]</span></label>
<label for="code">{{ __('admin::app.label') }}<span class="locale">[{{ $channel->code }} - {{ $locale->code }}]</span></label>
<input type="text" class="control" name="label[{{ $channel->code }}][{{ $locale->code }}]" v-model="label.{{ $channel->code }}.{{ $locale->code }}" data-vv-as="&quot;{{ __('admin::app.promotion.general-info.label') }}&quot;">
@ -430,25 +430,23 @@
name: null,
description: null,
conditions_list: [],
channels: [],
customer_groups: [],
channels: ['{{ core()->getCurrentChannel()->id }}'],
customer_groups: ['{{ app('Webkul\Customer\Repositories\CustomerGroupRepository')->findOneWhere(["code" => "general"])->id }}'],
ends_till: null,
starts_from: null,
priority: 0,
per_customer: 0,
status: null,
use_coupon: null,
status: 0,
use_coupon: 0,
auto_generation: false,
usage_limit: 0,
action_type: null,
apply: null,
apply_amt: false,
apply_prct: false,
apply_to_shipping: 0,
disc_amount: null,
disc_amount: 1,
// disc_threshold: null,
disc_quantity: null,
disc_quantity: 1,
end_other_rules: 0,
coupon_type: null,
free_shipping: 0,

View File

@ -242,7 +242,7 @@
<accordian :active="false" title="{{ __('admin::app.promotion.actions') }}">
<div slot="body">
<div class="control-group" :class="[errors.has('action_type') ? 'has-error' : '']">
<label for="action_type" class="required">{{ __('admin::app.promotion.general-info.apply') }}</label>
<label for="action_type" class="required">{{ __('admin::app.action') }}</label>
<select class="control" name="action_type" v-model="action_type" v-validate="'required'" value="{{ old('action_type') }}" data-vv-as="&quot;Apply As&quot;" v-on:change="detectApply">
<option v-for="(action, index) in actions" :value="index">@{{ action }}</option>
@ -259,14 +259,6 @@
<span class="control-error" v-if="errors.has('disc_amount')">@{{ errors.first('disc_amount') }}</span>
</div>
{{-- <div class="control-group" :class="[errors.has('disc_threshold') ? 'has-error' : '']">
<label for="disc_threshold" class="required">{{ __('admin::app.promotion.cart.buy-atleast') }}</label>
<input type="number" step="1" class="control" name="disc_threshold" v-model="disc_threshold" v-validate="'required|numeric|min_value:1'" value="{{ old('disc_threshold') }}" data-vv-as="&quot;{{ __('admin::app.promotion.cart.buy-atleast') }}&quot;">
<span class="control-error" v-if="errors.has('disc_threshold')">@{{ errors.first('disc_threshold') }}</span>
</div> --}}
<div class="control-group" :class="[errors.has('disc_quantity') ? 'has-error' : '']">
<label for="disc_quantity" class="required">{{ __('admin::app.promotion.general-info.disc_qty') }}</label>
@ -403,9 +395,10 @@
<accordian :active="false" :title="'{{ __('admin::app.promotion.general-info.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>
<label for="code">{{ __('admin::app.label') }}
<span class="locale">[{{ $label->channel->code }} - {{ $label->locale->code }}]</span>
</label>
<input type="text" class="control" name="label[{{ $label->channel->code }}][{{ $label->locale->code }}]" value="{{ $label->label }}" data-vv-as="&quot;Label&quot;">
@ -443,11 +436,8 @@
action_type: null,
apply: null,
apply_amt: false,
apply_prct: false,
apply_to_shipping: null,
disc_amount: null,
// disc_threshold: null,
disc_quantity: null,
end_other_rules: null,
coupon_type: null,
@ -556,10 +546,6 @@
this.apply = null;
this.apply_amt = false;
this.apply_prct = false;
this.apply_to_shipping = data.apply_to_shipping;
this.disc_amount = data.disc_amount;

View File

@ -779,7 +779,11 @@ abstract class Discount
$result = true;
foreach ($conditions as $condition) {
if (! isset($condition->attribute) || ! isset($condition->condition) || !isset($condition->value)) {
$result = true;
if (! isset($condition->attribute) || ! isset($condition->condition) || ! isset($condition->value) || ! isset($condition->type) || $condition->value != []) {
$result = false;
continue;
}
@ -804,55 +808,53 @@ abstract class Discount
$result = false;
}
if (isset($condition->type) && ($condition->type == 'numeric' || $condition->type == 'string' || $condition->type == 'text')) {
if ($condition->type == 'string') {
$actual_value = strtolower($actual_value);
if ($condition->type == 'string') {
$actual_value = strtolower($actual_value);
$test_value = strtolower($test_value);
$test_value = strtolower($test_value);
}
if ($test_condition == '=') {
if ($actual_value != $test_value) {
$result = false;
break;
}
} else if ($test_condition == '>=') {
if (! ($actual_value >= $test_value)) {
$result = false;
if ($test_condition == '=') {
if ($actual_value != $test_value) {
$result = false;
break;
}
} else if ($test_condition == '<=') {
if (! ($actual_value <= $test_value)) {
$result = false;
break;
}
} else if ($test_condition == '>=') {
if (! ($actual_value >= $test_value)) {
$result = false;
break;
}
} else if ($test_condition == '>') {
if (! ($actual_value > $test_value)) {
$result = false;
break;
}
} else if ($test_condition == '<=') {
if (! ($actual_value <= $test_value)) {
$result = false;
break;
}
} else if ($test_condition == '<') {
if (! ($actual_value < $test_value)) {
$result = false;
break;
}
} else if ($test_condition == '>') {
if (! ($actual_value > $test_value)) {
$result = false;
break;
}
} else if ($test_condition == '{}') {
if (! str_contains($actual_value, $test_value)) {
$result = false;
break;
}
} else if ($test_condition == '<') {
if (! ($actual_value < $test_value)) {
$result = false;
break;
}
} else if ($test_condition == '!{}') {
if (str_contains($actual_value, $test_value)) {
$result = false;
break;
}
} else if ($test_condition == '{}') {
if (! str_contains($actual_value, $test_value)) {
$result = false;
break;
}
} else if ($test_condition == '!{}') {
if (str_contains($actual_value, $test_value)) {
$result = false;
break;
}
break;
}
}
}

View File

@ -75,15 +75,13 @@ class ConvertXToProductId
$this->conditionSymbols = config('pricerules.cart.conditions.symbols');
}
public function convertX($attribute_conditions)
public function convertX($attributeConditions)
{
$attributeConditions = json_decode(json_decode($attribute_conditions));
$categoryValues = $attributeConditions->categories;
$categoryValues = $attributeConditions->categories ?? null;
$attributeValues = $attributeConditions->attributes;
$attributeValues = $attributeConditions->attributes ?? null;
if (!isset($categoryValues) && !isset($attributeValues)) {
if (! isset($categoryValues) && ! isset($attributeValues)) {
return false;
}
@ -115,71 +113,73 @@ class ConvertXToProductId
$products = collect();
foreach ($attributeOptions as $attributeOption) {
$selectedOptions = $attributeOption->value;
if (isset($attributeOption->type) && $attributeOption->name != null && $attributeOption->condition != null && $attributeOption->value != [] && $attributeOption->type != null) {
$selectedOptions = $attributeOption->value;
if ($attributeOption->type == 'select' || $attributeOption->type == 'multiselect') {
$attribute = $this->attribute->findWhere([
'code' => $attributeOption->attribute
]);
if ($attributeOption->type == 'select' || $attributeOption->type == 'multiselect') {
$attribute = $this->attribute->findWhere([
'code' => $attributeOption->attribute
]);
$attributeOptions = $attribute->first()->options;
$attributeOptions = $attribute->first()->options;
$selectedAttributeOptions = collect();
$selectedAttributeOptions = collect();
foreach ($attributeOptions as $attributeOption) {
foreach ($selectedOptions as $key => $value) {
if ($attributeOption->id == $value) {
$selectedAttributeOptions->push($attributeOption);
foreach ($attributeOptions as $attributeOption) {
foreach ($selectedOptions as $key => $value) {
if ($attributeOption->id == $value) {
$selectedAttributeOptions->push($attributeOption);
}
}
}
}
foreach ($selectedAttributeOptions as $selectedAttributeOption) {
$typeColumn = $this->pav::$attributeTypeFields[$attribute->first()->type];
foreach ($selectedAttributeOptions as $selectedAttributeOption) {
$typeColumn = $this->pav::$attributeTypeFields[$attribute->first()->type];
$pavResults = $this->pav->where(
"{$typeColumn}",
$selectedAttributeOption->id
)->get();
$pavResults = $this->pav->where(
"{$typeColumn}",
$selectedAttributeOption->id
)->get();
foreach ($pavResults as $pavResult) {
if ($pavResult->product->type == 'simple')
$products->push($pavResult->product);
foreach ($pavResults as $pavResult) {
if ($pavResult->product->type == 'simple')
$products->push($pavResult->product);
}
}
}
} else {
$attribute = $this->attribute->findWhere([
'code' => $attributeOption->attribute
]);
} else {
$attribute = $this->attribute->findWhere([
'code' => $attributeOption->attribute
]);
$pavValues = $attribute->first();
$pavValues = $attribute->first();
$selectedAttributeValues = collect();
$selectedAttributeValues = collect();
if ($attributeOption->attribute == 'sku') {
$testValue = $attributeOption->value;
$testCondition = $attributeOption->condition;
if ($attributeOption->attribute == 'sku') {
$testValue = $attributeOption->value;
$testCondition = $attributeOption->condition;
if ($testCondition == '{}') {
$foundProducts = $this->product->findWhere([
['sku', 'like', '%' . $testValue . '%'],
['type', '!=', 'configurable']
])->flatten()->all();
} else if ($testCondition == '!{}') {
$foundProducts = $this->product->findWhere([
['sku', 'not like', '%' . $testValue . '%'],
['type', '!=', 'configurable']
])->flatten()->all();
} else if ($testCondition == '=') {
$foundProducts = $this->product->findWhere([
['sku', '=', '%' . $testValue . '%'],
['type', '!=', 'configurable']
])->flatten()->all();
if ($testCondition == '{}') {
$foundProducts = $this->product->findWhere([
['sku', 'like', '%' . $testValue . '%'],
['type', '!=', 'configurable']
])->flatten()->all();
} else if ($testCondition == '!{}') {
$foundProducts = $this->product->findWhere([
['sku', 'not like', '%' . $testValue . '%'],
['type', '!=', 'configurable']
])->flatten()->all();
} else if ($testCondition == '=') {
$foundProducts = $this->product->findWhere([
['sku', '=', '%' . $testValue . '%'],
['type', '!=', 'configurable']
])->flatten()->all();
}
}
}
foreach ($foundProducts as $foundProduct) {
$products->push($foundProduct);
foreach ($foundProducts as $foundProduct) {
$products->push($foundProduct);
}
}
}
}

View File

@ -70,6 +70,10 @@ abstract class Sale
if ($rule->conditions) {
$conditions = $rule->conditions;
while(gettype($conditions) == 'string') {
$conditions = json_decode($conditions);
}
$productIDs = $this->convertX->convertX($conditions);
} else {
$productIDs = '*';

View File

@ -407,11 +407,11 @@ class CatalogRuleController extends Controller
$catalogRule = $this->catalogRule->findOrFail($id);
if ($catalogRule->delete()) {
session()->flash('success', trans('admin::app.promotion.delete-success'));
session()->flash('success', trans('admin::app.promotion.status.delete-success'));
return response()->json(['message' => true], 200);
} else {
session()->flash('success', trans('admin::app.promotion.delete-failed'));
session()->flash('error', trans('admin::app.promotion.status.delete-failed'));
return response()->json(['message' => false], 400);
}

View File

@ -190,7 +190,7 @@
created: function () {
if (!this.index)
this.active = true;
this.active = false;
if (this.appliedFilterValues && this.appliedFilterValues.length) {
this.appliedFilters = this.appliedFilterValues;