Cart rule form variables normalized
This commit is contained in:
parent
cc565ad5ec
commit
c190f6f230
|
|
@ -457,8 +457,8 @@
|
|||
match_criteria: 'all_are_true',
|
||||
|
||||
all_attributes: {
|
||||
'categories' : null,
|
||||
'attributes' : null
|
||||
'categories' : [],
|
||||
'attributes' : []
|
||||
},
|
||||
|
||||
code: null,
|
||||
|
|
@ -547,13 +547,7 @@
|
|||
},
|
||||
|
||||
detectApply() {
|
||||
if (this.apply == 'percent_of_product' || this.apply == 'buy_a_get_b') {
|
||||
this.apply_prct = true;
|
||||
this.apply_amt = false;
|
||||
} else if (this.apply == 'fixed_amount' || this.apply == 'fixed_amount_cart') {
|
||||
this.apply_prct = false;
|
||||
this.apply_amt = true;
|
||||
}
|
||||
return;
|
||||
},
|
||||
|
||||
enableCondition(event, index) {
|
||||
|
|
@ -597,26 +591,25 @@
|
|||
},
|
||||
|
||||
onSubmit: function (e) {
|
||||
if (this.attribute_values != null || this.category_values != null) {
|
||||
if (this.attribute_values.length != 0 || this.category_values.length != 0) {
|
||||
for (i in this.attribute_values) {
|
||||
delete this.attribute_values[i].options;
|
||||
}
|
||||
|
||||
if (this.category_values != null) {
|
||||
this.all_attributes.categories = this.category_values;
|
||||
}
|
||||
this.all_attributes.categories = this.category_values;
|
||||
|
||||
this.all_attributes.attributes = this.attribute_values;
|
||||
|
||||
this.all_attributes = JSON.stringify(this.all_attributes);
|
||||
} else {
|
||||
this.all_attributes = null;
|
||||
}
|
||||
|
||||
this.all_attributes = JSON.stringify(this.all_attributes);
|
||||
|
||||
if (this.conditions_list.length != 0) {
|
||||
this.conditions_list.push({'criteria': this.match_criteria});
|
||||
|
||||
this.all_conditions = JSON.stringify(this.conditions_list);
|
||||
|
||||
this.conditions_list.pop();
|
||||
}
|
||||
|
||||
this.$validator.validateAll().then(result => {
|
||||
|
|
|
|||
|
|
@ -489,9 +489,10 @@
|
|||
country_and_states: @json($cart_rule[2]),
|
||||
|
||||
category_options: @json($cart_rule[1]),
|
||||
category_values: [],
|
||||
|
||||
category_values: [],
|
||||
attribute_values: [],
|
||||
|
||||
attr_object: {
|
||||
attribute: null,
|
||||
condition: null,
|
||||
|
|
@ -504,12 +505,11 @@
|
|||
|
||||
mounted () {
|
||||
data = @json($cart_rule[3]);
|
||||
|
||||
this.name = data.name;
|
||||
|
||||
this.description = data.description;
|
||||
|
||||
this.conditions_list = [];
|
||||
|
||||
this.channels = [];
|
||||
|
||||
for (i in data.channels) {
|
||||
|
|
@ -576,22 +576,25 @@
|
|||
|
||||
this.all_conditions = null;
|
||||
|
||||
if (data.conditions != null) {
|
||||
if (data.hasOwnProperty('conditions') && data.conditions != null) {
|
||||
this.conditions_list = JSON.parse(JSON.parse(data.conditions));
|
||||
|
||||
this.match_criteria = this.conditions_list.pop().criteria;
|
||||
}
|
||||
|
||||
if (JSON.parse(data.actions).attribute_conditions) {
|
||||
this.category_values = JSON.parse(data.actions).attribute_conditions.categories;
|
||||
hasSubSelectionConditions = JSON.parse(data.actions).hasOwnProperty('attribute_conditions');
|
||||
|
||||
this.attribute_values = JSON.parse(data.actions).attribute_conditions.attributes;
|
||||
if (hasSubSelectionConditions) {
|
||||
|
||||
if (this.category_values == null) {
|
||||
if (JSON.parse(data.actions).attribute_conditions.hasOwnProperty('categories')) {
|
||||
this.category_values = JSON.parse(data.actions).attribute_conditions.categories;
|
||||
} else {
|
||||
this.category_values = [];
|
||||
}
|
||||
|
||||
if (this.attribute_values == null) {
|
||||
if (JSON.parse(data.actions).attribute_conditions.hasOwnProperty('attributes')) {
|
||||
this.attribute_values = JSON.parse(data.actions).attribute_conditions.attributes;
|
||||
} else {
|
||||
this.attribute_values = [];
|
||||
}
|
||||
|
||||
|
|
@ -714,7 +717,7 @@
|
|||
},
|
||||
|
||||
onSubmit: function (e) {
|
||||
if (this.attribute_values != null || this.category_values != null) {
|
||||
if (this.attribute_values.length != 0 || this.category_values.length != 0) {
|
||||
for (i in this.attribute_values) {
|
||||
delete this.attribute_values[i].options;
|
||||
}
|
||||
|
|
@ -728,7 +731,7 @@
|
|||
this.all_attributes = null;
|
||||
}
|
||||
|
||||
if (this.conditions_list != null) {
|
||||
if (this.conditions_list.length != 0) {
|
||||
this.conditions_list.push({'criteria': this.match_criteria});
|
||||
|
||||
this.all_conditions = JSON.stringify(this.conditions_list);
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ class CartRuleController extends Controller
|
|||
'action_type' => $data['action_type'],
|
||||
'disc_amount' => $data['disc_amount'],
|
||||
'disc_quantity' => $data['disc_quantity'],
|
||||
'attribute_conditions' => json_encode($attribute_conditions)
|
||||
'attribute_conditions' => $attribute_conditions
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue