[Fix] Auto add item in the cart if sinfle items found in the serach (#11072)
This commit is contained in:
parent
607b5d4985
commit
e0dfd1608e
@ -948,6 +948,7 @@ class POSItems {
|
||||
if (this.search_index[search_term]) {
|
||||
const items = this.search_index[search_term];
|
||||
this.render_items(items);
|
||||
this.set_item_in_the_cart(items);
|
||||
return;
|
||||
}
|
||||
} else if (item_group == "All Item Groups") {
|
||||
@ -961,19 +962,32 @@ class POSItems {
|
||||
}
|
||||
|
||||
this.render_items(items);
|
||||
if(serial_no) {
|
||||
this.events.update_cart(items[0].item_code,
|
||||
'serial_no', serial_no);
|
||||
this.reset_search_field();
|
||||
}
|
||||
if(batch_no) {
|
||||
this.events.update_cart(items[0].item_code,
|
||||
'batch_no', batch_no);
|
||||
this.reset_search_field();
|
||||
}
|
||||
this.set_item_in_the_cart(items, serial_no, batch_no);
|
||||
});
|
||||
}
|
||||
|
||||
set_item_in_the_cart(items, serial_no, batch_no) {
|
||||
if (serial_no) {
|
||||
this.events.update_cart(items[0].item_code,
|
||||
'serial_no', serial_no);
|
||||
this.reset_search_field();
|
||||
return;
|
||||
}
|
||||
|
||||
if (batch_no) {
|
||||
this.events.update_cart(items[0].item_code,
|
||||
'batch_no', batch_no);
|
||||
this.reset_search_field();
|
||||
return;
|
||||
}
|
||||
|
||||
if (items.length === 1) {
|
||||
this.events.update_cart(items[0].item_code,
|
||||
'qty', '+1');
|
||||
this.reset_search_field();
|
||||
}
|
||||
}
|
||||
|
||||
reset_search_field() {
|
||||
this.search_field.set_value('');
|
||||
this.search_field.$input.trigger("input");
|
||||
|
Loading…
x
Reference in New Issue
Block a user