update addorder bugs
This commit is contained in:
@@ -8,12 +8,6 @@ $(function(){
|
||||
});
|
||||
//End menu category Click
|
||||
|
||||
$(".change_qty").change(function(){
|
||||
qty = $(this).val();
|
||||
price = $("#unit_price").text();
|
||||
$("#total_price").text(qty*price);
|
||||
});
|
||||
|
||||
$("#set_change_qty").change(function(){
|
||||
qty = $(this).val();
|
||||
price = $("#set_total_price").text();
|
||||
@@ -34,7 +28,6 @@ $(function(){
|
||||
var menu_items_list = $('.menu_items_list');
|
||||
menu_items_list.empty();
|
||||
menu_items = data.menu_items;
|
||||
|
||||
for(var field in menu_items) {
|
||||
if (menu_items[field].is_sub_item == false) {
|
||||
instances = menu_items[field].instances ;
|
||||
@@ -64,6 +57,12 @@ $(function(){
|
||||
data_target = 'sx_item_detailModal'
|
||||
}
|
||||
|
||||
if (menu_items[field].image) {
|
||||
image_path = menu_items[field].image;
|
||||
}else{
|
||||
image_path = "/image/logo.png";
|
||||
}
|
||||
|
||||
row = '<div class="card custom-card">'
|
||||
+'<div class="custom-card-head card-head" style="line-height:14px;">'
|
||||
+'<small class="col-md-9">'+ menu_items[field].name +'</small>'
|
||||
@@ -73,7 +72,7 @@ $(function(){
|
||||
+ price +"' data-instance-code = '"+ code +"' data-instance = '"
|
||||
+ name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '"
|
||||
+ JSON.stringify(item_attributes) +"' data-options = '"
|
||||
+ options +"'>"
|
||||
+ options +"' data-image='"+image_path+"'>"
|
||||
+"<i class='fa "+fa_plus+" '"
|
||||
+ 'style="margin-top:4px;">'
|
||||
+'</i></div>'
|
||||
@@ -88,7 +87,7 @@ $(function(){
|
||||
+JSON.stringify(menu_items[field].item_sets)+"' data-toggle='modal' data-target='."+data_target+"'>"
|
||||
|
||||
+"<div class='card-block custom-card-block'>"
|
||||
+"<img id='logo' src='/image/logo.png'>"
|
||||
+"<img id='logo' src='"+image_path+"'>"
|
||||
|
||||
+"</div>"
|
||||
|
||||
@@ -242,6 +241,7 @@ $(function(){
|
||||
$(document).on('click', '.menu_item_box', function(event){
|
||||
$('.attributes-list').empty();
|
||||
$('.options-list').empty();
|
||||
$('#modal_box_img').empty();
|
||||
$('.attr-alert').addClass('hide');
|
||||
$('.add_to_order').removeAttr('data-instance-code');
|
||||
$('.add_to_order').removeAttr('data-instance');
|
||||
@@ -254,11 +254,21 @@ $(function(){
|
||||
$('.add_to_order').removeAttr('data-options');
|
||||
|
||||
data = $(this).parent().children().children('.add_icon');
|
||||
|
||||
$('#total_price').text(data.attr('data-price'));
|
||||
attributes = $(this).data('id');
|
||||
selected_item = $(this).data('item');
|
||||
instances = $(this).data('instance');
|
||||
item_options = $(this).data('option');
|
||||
|
||||
if (data.attr('data-image')) {
|
||||
image = "<img id='' src='"+data.attr('data-image')+"'>";
|
||||
}else{
|
||||
image = "<img id='' src='/image/logo.png'>";
|
||||
}
|
||||
|
||||
$('#modal_box_img').append(image);
|
||||
|
||||
instance_attributes = []
|
||||
for(var field in instances) {
|
||||
value = instances[field].values;
|
||||
@@ -303,10 +313,13 @@ $(function(){
|
||||
$(".options-list").append(row);
|
||||
}
|
||||
|
||||
$('#change_qty').val(1);
|
||||
$('#count').val(1);
|
||||
$('#item_instances').text(instances);
|
||||
$('#title_name').text(data.attr('data-name'));
|
||||
$('#item_code').text(data.attr('data-item-code'));
|
||||
$('#instance_name').text(data.attr('data-instance'));
|
||||
$('#instance_code').text(data.attr('data-instance-code'));
|
||||
$('#promotion_price').text(data.attr('data-promotion-price'));
|
||||
$('#total_price').text(data.attr('data-price'));
|
||||
$('#unit_price').text(data.attr('data-price'));
|
||||
});
|
||||
@@ -382,23 +395,30 @@ $(function(){
|
||||
// click add order
|
||||
$(document).on('click', '.add_to_order', function(event){
|
||||
total_price = $('#total_price').text();
|
||||
qty = parseInt($('#change_qty').val());
|
||||
qty = parseInt($('#count').val());
|
||||
|
||||
var item_row = $('.selected-attribute');
|
||||
var instances = jQuery.parseJSON(item_row.attr('data-instances'));
|
||||
|
||||
|
||||
attribute_arr = get_selected_attributes('selected-attribute');
|
||||
option_arr = get_selected_attributes('selected-option');
|
||||
|
||||
for(var field in instances) {
|
||||
if (JSON.stringify(attribute_arr) === JSON.stringify(instances[field].values)) {
|
||||
|
||||
$('.add_to_order').attr('data-instance-code',instances[field].code);
|
||||
$('.add_to_order').attr('data-instance',instances[field].name);
|
||||
$('.add_to_order').attr('data-price',instances[field].price);
|
||||
$('.add_to_order').attr('data-promotion-price',instances[field].promotion_price);
|
||||
if (item_row.length>0) {
|
||||
var instances = jQuery.parseJSON(item_row.attr('data-instances'));
|
||||
for(var field in instances) {
|
||||
if (JSON.stringify(attribute_arr) === JSON.stringify(instances[field].values)) {
|
||||
$('.add_to_order').attr('data-instance-code',instances[field].code);
|
||||
$('.add_to_order').attr('data-instance',instances[field].name);
|
||||
$('.add_to_order').attr('data-price',instances[field].price);
|
||||
$('.add_to_order').attr('data-promotion-price',instances[field].promotion_price);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$('.add_to_order').attr('data-instance-code',$('#instance_code').text());
|
||||
$('.add_to_order').attr('data-instance',$('#instance_name').text());
|
||||
$('.add_to_order').attr('data-price',$('#unit_price').text());
|
||||
$('.add_to_order').attr('data-promotion-price',$('#promotion_price').text());
|
||||
}
|
||||
|
||||
$('.add_to_order').attr('data-item-code',$('#item_code').text());
|
||||
$('.add_to_order').attr('data-qty',qty);
|
||||
$('.add_to_order').attr('data-name',$('#title_name').text());
|
||||
@@ -621,4 +641,40 @@ $(function(){
|
||||
return attribute_arr;
|
||||
}
|
||||
|
||||
//click menu sidebar menu category
|
||||
$("#back").on("click", function(){
|
||||
var table_id = $('#table_id').text();
|
||||
var table_type = $('#table_type').text();
|
||||
if(table_type == "Table"){
|
||||
window.location.href = "/origami/table/" + table_id
|
||||
}else {
|
||||
window.location.href = "/origami/room/" + table_id
|
||||
}
|
||||
});
|
||||
|
||||
var count = 1;
|
||||
var countEl = document.getElementById("count");
|
||||
$("#plus").on("click", function(){
|
||||
count++;
|
||||
countEl.value = count;
|
||||
|
||||
price = $("#unit_price").text();
|
||||
$("#total_price").text(count*price);
|
||||
});
|
||||
$("#minus").on("click", function(){
|
||||
if (count > 1) {
|
||||
count--;
|
||||
countEl.value = count;
|
||||
|
||||
price = $("#unit_price").text();
|
||||
$("#total_price").text(count*price);
|
||||
}
|
||||
})
|
||||
|
||||
// $(".change_qty").change(function(){
|
||||
// qty = $(this).val();
|
||||
// price = $("#unit_price").text();
|
||||
// $("#total_price").text(qty*price);
|
||||
// });
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user