fix oos
This commit is contained in:
@@ -255,7 +255,7 @@ $(function() {
|
||||
}
|
||||
else {
|
||||
price_tag = '<span>'+result[v]["price"]+'</span>'
|
||||
pointer_event = 'cursor'
|
||||
pointer_event = 'auto'
|
||||
opacity = ''
|
||||
}
|
||||
|
||||
@@ -371,8 +371,7 @@ $(function() {
|
||||
rowCount = $('.selected-instance');
|
||||
setCount = $('.selected-set');
|
||||
item_options = $(this).data('option');
|
||||
console.log(item_options);
|
||||
|
||||
|
||||
min_qty = $(this).data('min-qty');
|
||||
max_qty = $(this).data('max-qty');
|
||||
|
||||
@@ -774,7 +773,6 @@ $(function() {
|
||||
type = $(this).data('type');
|
||||
instances = $(this).data('instances');
|
||||
item_attributes = $(this).data('attributes');
|
||||
selected_values = []
|
||||
|
||||
attributes = $(".attribute_btn");
|
||||
$(attributes).each(function(i){
|
||||
@@ -784,45 +782,6 @@ $(function() {
|
||||
});
|
||||
$(this).addClass('selected-attribute');
|
||||
|
||||
$('button.selected-attribute').each(function(i) {
|
||||
selected_values.push($(this).data('value'));
|
||||
})
|
||||
|
||||
for(var sv in selected_values) {
|
||||
current_type = $('.attributes-list').find(`button[data-value='${selected_values[sv]}']`).data('type')
|
||||
for (var i in item_attributes) {
|
||||
available_btn = []
|
||||
if (item_attributes[i].type != current_type) {
|
||||
for(var j in instances) {
|
||||
if (instances[j].values.includes(selected_values[sv]) && instances[j].out_of_stock == false) {
|
||||
$.map(instances[j].values, function(v) {
|
||||
if (v != selected_values[sv]) {
|
||||
available_btn.push(v)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
if (available_btn.length == 0) {
|
||||
element = $('.attributes-list').find(`button[data-type!='${current_type}']`)
|
||||
$.map(element, function(elem) {
|
||||
if (!$(elem).hasClass('bg-gray')) {
|
||||
$(elem).addClass('bg-gray box-shadow-none');
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$.map(available_btn, function(btn) {
|
||||
element = $('.attributes-list').find(`button[data-type !='${current_type}'][data-value!='${btn}']`)
|
||||
$.map(element, function(elem) {
|
||||
if (!$(elem).hasClass('bg-gray') && !available_btn.includes($(elem).data('value'))) {
|
||||
$(elem).addClass('bg-gray box-shadow-none')
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var selected_attr = get_selected_attributes('selected-attribute');
|
||||
|
||||
qty = $('.change_qty').val();
|
||||
@@ -839,19 +798,10 @@ $(function() {
|
||||
selected_attr = selected_attr.sort()
|
||||
if(JSON.stringify(item_attr) == JSON.stringify(selected_attr)){
|
||||
if (instances[field].out_of_stock) {
|
||||
var text = ''
|
||||
var length = 0
|
||||
for (var i in selected_attr) {
|
||||
length += 1;
|
||||
if (length == selected_attr.length) {
|
||||
text += selected_attr[i]
|
||||
}
|
||||
else {
|
||||
text += selected_attr[i]+'-'
|
||||
}
|
||||
}
|
||||
total_price = instances[field].price;
|
||||
$('#total_price').text(total_price);
|
||||
$('#wanring_text').text('')
|
||||
$('#wanring_text').append('<strong>' + text + '</strong> is out of stock.')
|
||||
$('#wanring_text').append('<strong>Out of stock</strong>')
|
||||
$('#add_to_order').attr('disabled', true)
|
||||
$('#minus').attr('disabled', true);
|
||||
$('#plus').attr('disabled', true);
|
||||
@@ -877,19 +827,8 @@ $(function() {
|
||||
$('#plus').removeAttr('disabled');
|
||||
$('#count').removeAttr('readonly')
|
||||
} else {
|
||||
var text = ''
|
||||
var length = 0
|
||||
for (var i in selected_attr) {
|
||||
length += 1;
|
||||
if (length == selected_attr.length) {
|
||||
text += selected_attr[i]
|
||||
}
|
||||
else {
|
||||
text += selected_attr[i]+'-'
|
||||
}
|
||||
}
|
||||
$('#wanring_text').text('')
|
||||
$('#wanring_text').append('<strong>' + text + '</strong> is not available.')
|
||||
$('#wanring_text').append('<strong>Not available</strong>')
|
||||
$('#add_to_order').attr('disabled', true)
|
||||
$('#minus').attr('disabled', true);
|
||||
$('#plus').attr('disabled', true);
|
||||
@@ -1724,7 +1663,6 @@ $(function() {
|
||||
function show_menu_list(menu_items) {
|
||||
var menu_list = $('.menu_items_list');
|
||||
menu_list.empty();
|
||||
console.log(menu_items);
|
||||
for(var field in menu_items) {
|
||||
if (menu_items[field].is_sub_item == false) {
|
||||
instances = menu_items[field].instances ;
|
||||
@@ -1782,7 +1720,7 @@ $(function() {
|
||||
});
|
||||
}
|
||||
|
||||
pointer_event = 'cursor'
|
||||
pointer_event = 'auto'
|
||||
opacity = ''
|
||||
status = ''
|
||||
count = 0;
|
||||
@@ -1798,56 +1736,31 @@ $(function() {
|
||||
}
|
||||
})
|
||||
|
||||
if (JSON.stringify(menu_items[field].item_sets)!='[]') { // check all item_sets out of stock??
|
||||
item_sets = menu_items[field].item_sets
|
||||
oos_count = 0
|
||||
available_count = 0
|
||||
for(var f in item_sets) {
|
||||
value = item_sets[f]["instances"];
|
||||
$(value).each(function(i){
|
||||
menus = JSON.parse(localStorage.getItem("menus"));
|
||||
if (menus != null) {
|
||||
for(var j in menus) {
|
||||
var categories = menus[j]["categories"];
|
||||
for(var ii in categories) {
|
||||
var items = categories[ii]["items"];
|
||||
for(var iii in items) {
|
||||
var result = items[iii]["instances"];
|
||||
for(var v in result) {
|
||||
if (value[i]["id"] == result[v]["id"]) {
|
||||
if (result[v].is_available) {
|
||||
available_count += 1
|
||||
if (result[v].out_of_stock) {
|
||||
oos_count += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
if(available_count == oos_count) {
|
||||
pointer_event = 'none'
|
||||
opacity = '0.5'
|
||||
status = 'out of stock'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (status) {
|
||||
price_tag = '<span class="text-danger" style="font-weight:900;flex-grow:1;">'+status+'</span>'
|
||||
} else {
|
||||
price_tag ='<span style="font-weight:900;flex-grow:1;">'+price+'</span>'
|
||||
}
|
||||
|
||||
|
||||
image_path = '';
|
||||
image_exist = false;
|
||||
if (menu_items[field].image) {
|
||||
if (modify_order) {
|
||||
image_path = "../../"+menu_items[field].image;
|
||||
}else{
|
||||
image_path = menu_items[field].image;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: image_path,
|
||||
async: false,
|
||||
success: function(data) {
|
||||
image_exist = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(image_exist == true) {
|
||||
oos_item = '<div class="card custom-card testimonial-card fadeInRight" id="'+ code +'" style="height: 100%; pointer-events: '+pointer_event+';">'
|
||||
name = menu_items[field].name
|
||||
short_name = truncateString(name, 30)
|
||||
|
||||
Reference in New Issue
Block a user