fix oos
This commit is contained in:
@@ -255,7 +255,7 @@ $(function() {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
price_tag = '<span>'+result[v]["price"]+'</span>'
|
price_tag = '<span>'+result[v]["price"]+'</span>'
|
||||||
pointer_event = 'cursor'
|
pointer_event = 'auto'
|
||||||
opacity = ''
|
opacity = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,7 +371,6 @@ $(function() {
|
|||||||
rowCount = $('.selected-instance');
|
rowCount = $('.selected-instance');
|
||||||
setCount = $('.selected-set');
|
setCount = $('.selected-set');
|
||||||
item_options = $(this).data('option');
|
item_options = $(this).data('option');
|
||||||
console.log(item_options);
|
|
||||||
|
|
||||||
min_qty = $(this).data('min-qty');
|
min_qty = $(this).data('min-qty');
|
||||||
max_qty = $(this).data('max-qty');
|
max_qty = $(this).data('max-qty');
|
||||||
@@ -774,7 +773,6 @@ $(function() {
|
|||||||
type = $(this).data('type');
|
type = $(this).data('type');
|
||||||
instances = $(this).data('instances');
|
instances = $(this).data('instances');
|
||||||
item_attributes = $(this).data('attributes');
|
item_attributes = $(this).data('attributes');
|
||||||
selected_values = []
|
|
||||||
|
|
||||||
attributes = $(".attribute_btn");
|
attributes = $(".attribute_btn");
|
||||||
$(attributes).each(function(i){
|
$(attributes).each(function(i){
|
||||||
@@ -784,45 +782,6 @@ $(function() {
|
|||||||
});
|
});
|
||||||
$(this).addClass('selected-attribute');
|
$(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');
|
var selected_attr = get_selected_attributes('selected-attribute');
|
||||||
|
|
||||||
qty = $('.change_qty').val();
|
qty = $('.change_qty').val();
|
||||||
@@ -839,19 +798,10 @@ $(function() {
|
|||||||
selected_attr = selected_attr.sort()
|
selected_attr = selected_attr.sort()
|
||||||
if(JSON.stringify(item_attr) == JSON.stringify(selected_attr)){
|
if(JSON.stringify(item_attr) == JSON.stringify(selected_attr)){
|
||||||
if (instances[field].out_of_stock) {
|
if (instances[field].out_of_stock) {
|
||||||
var text = ''
|
total_price = instances[field].price;
|
||||||
var length = 0
|
$('#total_price').text(total_price);
|
||||||
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').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)
|
$('#add_to_order').attr('disabled', true)
|
||||||
$('#minus').attr('disabled', true);
|
$('#minus').attr('disabled', true);
|
||||||
$('#plus').attr('disabled', true);
|
$('#plus').attr('disabled', true);
|
||||||
@@ -877,19 +827,8 @@ $(function() {
|
|||||||
$('#plus').removeAttr('disabled');
|
$('#plus').removeAttr('disabled');
|
||||||
$('#count').removeAttr('readonly')
|
$('#count').removeAttr('readonly')
|
||||||
} else {
|
} 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').text('')
|
||||||
$('#wanring_text').append('<strong>' + text + '</strong> is not available.')
|
$('#wanring_text').append('<strong>Not available</strong>')
|
||||||
$('#add_to_order').attr('disabled', true)
|
$('#add_to_order').attr('disabled', true)
|
||||||
$('#minus').attr('disabled', true);
|
$('#minus').attr('disabled', true);
|
||||||
$('#plus').attr('disabled', true);
|
$('#plus').attr('disabled', true);
|
||||||
@@ -1724,7 +1663,6 @@ $(function() {
|
|||||||
function show_menu_list(menu_items) {
|
function show_menu_list(menu_items) {
|
||||||
var menu_list = $('.menu_items_list');
|
var menu_list = $('.menu_items_list');
|
||||||
menu_list.empty();
|
menu_list.empty();
|
||||||
console.log(menu_items);
|
|
||||||
for(var field in menu_items) {
|
for(var field in menu_items) {
|
||||||
if (menu_items[field].is_sub_item == false) {
|
if (menu_items[field].is_sub_item == false) {
|
||||||
instances = menu_items[field].instances ;
|
instances = menu_items[field].instances ;
|
||||||
@@ -1782,7 +1720,7 @@ $(function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pointer_event = 'cursor'
|
pointer_event = 'auto'
|
||||||
opacity = ''
|
opacity = ''
|
||||||
status = ''
|
status = ''
|
||||||
count = 0;
|
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) {
|
if (status) {
|
||||||
price_tag = '<span class="text-danger" style="font-weight:900;flex-grow:1;">'+status+'</span>'
|
price_tag = '<span class="text-danger" style="font-weight:900;flex-grow:1;">'+status+'</span>'
|
||||||
} else {
|
} else {
|
||||||
price_tag ='<span style="font-weight:900;flex-grow:1;">'+price+'</span>'
|
price_tag ='<span style="font-weight:900;flex-grow:1;">'+price+'</span>'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
image_path = '';
|
||||||
|
image_exist = false;
|
||||||
if (menu_items[field].image) {
|
if (menu_items[field].image) {
|
||||||
if (modify_order) {
|
if (modify_order) {
|
||||||
image_path = "../../"+menu_items[field].image;
|
image_path = "../../"+menu_items[field].image;
|
||||||
}else{
|
}else{
|
||||||
image_path = menu_items[field].image;
|
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+';">'
|
oos_item = '<div class="card custom-card testimonial-card fadeInRight" id="'+ code +'" style="height: 100%; pointer-events: '+pointer_event+';">'
|
||||||
name = menu_items[field].name
|
name = menu_items[field].name
|
||||||
short_name = truncateString(name, 30)
|
short_name = truncateString(name, 30)
|
||||||
|
|||||||
@@ -337,7 +337,7 @@
|
|||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<div class="mr-auto">
|
<div class="mr-auto">
|
||||||
<h4 class=" pull-left d-inline">Total : <span id="total_price"></span></h4>
|
<h4 class=" pull-left d-inline">Total : <span id="total_price"></span></h4>
|
||||||
<div id="wanring_text" class="d-inline text-danger" style="margin-left: 50px"></div>
|
<h5 id="wanring_text" class="d-inline text-danger" style="margin-left: 50px"></h5>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
|
|||||||
Reference in New Issue
Block a user