update addorder available and max qty
This commit is contained in:
@@ -10,6 +10,7 @@ $(function(){
|
||||
|
||||
//show menu item list when click menu category
|
||||
function show_menu_item_list(url_item){
|
||||
|
||||
var menu_list = $('.menu_items_list');
|
||||
menu_list.empty();
|
||||
//Start Ajax
|
||||
@@ -22,6 +23,7 @@ $(function(){
|
||||
var menu_items_list = $('.menu_items_list');
|
||||
menu_items_list.empty();
|
||||
menu_items = data.menu_items;
|
||||
console.log(url_item);
|
||||
for(var field in menu_items) {
|
||||
if (menu_items[field].is_sub_item == false) {
|
||||
instances = menu_items[field].instances ;
|
||||
@@ -110,6 +112,7 @@ $(function(){
|
||||
for(var field in item_sets) {
|
||||
value = item_sets[field]["instances"];
|
||||
$(value).each(function(i){
|
||||
console.log(value);
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: '../../api/restaurant/menu_item_instances/'+value[i]["id"],
|
||||
@@ -121,6 +124,8 @@ $(function(){
|
||||
+"' data-code='"+result["code"]
|
||||
+"' data-price='"+result["price"]
|
||||
+"' data-option='"+JSON.stringify(result["options"])
|
||||
+"' data-min-qty='"+item_sets[field]["min_selectable_qty"]
|
||||
+"' data-max-qty='"+item_sets[field]["max_selectable_qty"]
|
||||
+"'>"
|
||||
+'<div class="custom-card-head card-head" style="line-height:14px;">'
|
||||
+'<small class="">'+result["name"]+'</small>'
|
||||
@@ -157,6 +162,8 @@ $(function(){
|
||||
$(".options-list").empty();
|
||||
|
||||
item_options = $(this).data('option');
|
||||
min_qty = $(this).data('min-qty');
|
||||
max_qty = $(this).data('max-qty');
|
||||
code = $(this).data('code');
|
||||
|
||||
for(var field in item_options) {
|
||||
@@ -171,31 +178,35 @@ $(function(){
|
||||
$(".options-list").append(row);
|
||||
}
|
||||
|
||||
if($(this).hasClass('selected-instance') == true){
|
||||
sub_total = $('#set_total_price').text();
|
||||
name = $(this).data('name');
|
||||
price = $(this).data('price');
|
||||
// qty = $('#set_change_qty').val();
|
||||
qty = document.getElementById("set_count").value;
|
||||
total = qty*price;
|
||||
var total_price = +sub_total - +total;
|
||||
$(this).removeClass('selected-instance');
|
||||
$(".options-list").empty();
|
||||
$(this).removeAttr('data-options');
|
||||
$('#instance_option').text('')
|
||||
}else {
|
||||
console.log($('.selected-instance').length)
|
||||
|
||||
sub_total = $('#set_total_price').text();
|
||||
name = $(this).data('name');
|
||||
price = $(this).data('price');
|
||||
// qty = $('#set_change_qty').val();
|
||||
qty = document.getElementById("set_count").value;
|
||||
total = qty*price;
|
||||
var total_price = +sub_total + +total;
|
||||
$(this).addClass('selected-instance');
|
||||
}
|
||||
$('#set_unit_price').text(price);
|
||||
$('#set_total_price').text(total_price);
|
||||
if($(this).hasClass('selected-instance') == true){
|
||||
sub_total = $('#set_total_price').text();
|
||||
name = $(this).data('name');
|
||||
price = $(this).data('price');
|
||||
// qty = $('#set_change_qty').val();
|
||||
qty = document.getElementById("set_count").value;
|
||||
total = qty*price;
|
||||
var total_price = +sub_total - +total;
|
||||
$(this).removeClass('selected-instance');
|
||||
$(".options-list").empty();
|
||||
$(this).removeAttr('data-options');
|
||||
$('#instance_option').text('')
|
||||
}else {
|
||||
if ($('.selected-instance').length+1 <= max_qty) {
|
||||
sub_total = $('#set_total_price').text();
|
||||
name = $(this).data('name');
|
||||
price = $(this).data('price');
|
||||
// qty = $('#set_change_qty').val();
|
||||
qty = document.getElementById("set_count").value;
|
||||
total = qty*price;
|
||||
var total_price = +sub_total + +total;
|
||||
$(this).addClass('selected-instance');
|
||||
}
|
||||
}
|
||||
$('#set_unit_price').text(price);
|
||||
$('#set_total_price').text(total_price);
|
||||
|
||||
}); //End selecct attribute buttom
|
||||
|
||||
// click add order
|
||||
|
||||
Reference in New Issue
Block a user