mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-24 23:49:19 +00:00
fix: E-commerce issue with Item Variants
This commit is contained in:
@@ -186,14 +186,14 @@ class ItemConfigure {
|
||||
this.dialog.$status_area.empty();
|
||||
}
|
||||
|
||||
get_html_for_item_found({ filtered_items_count, filtered_items, exact_match, product_info }) {
|
||||
get_html_for_item_found({ filtered_items_count, filtered_items, exact_match, product_info, available_qty, settings }) {
|
||||
const one_item = exact_match.length === 1
|
||||
? exact_match[0]
|
||||
: filtered_items_count === 1
|
||||
? filtered_items[0]
|
||||
: '';
|
||||
|
||||
const item_add_to_cart = one_item ? `
|
||||
let item_add_to_cart = one_item ? `
|
||||
<button data-item-code="${one_item}"
|
||||
class="btn btn-primary btn-add-to-cart w-100"
|
||||
data-action="btn_add_to_cart"
|
||||
@@ -218,6 +218,9 @@ class ItemConfigure {
|
||||
? '(' + product_info.price.formatted_price_sales_uom + ')'
|
||||
: ''
|
||||
}
|
||||
|
||||
${available_qty === 0 ? '<span class="text-danger">(' + __('Out of Stock') + ')</span>' : ''}
|
||||
|
||||
</div></div>
|
||||
<a href data-action="btn_clear_values" data-item-code="${one_item}">
|
||||
${__('Clear Values')}
|
||||
@@ -233,6 +236,10 @@ class ItemConfigure {
|
||||
</div>`;
|
||||
/* eslint-disable indent */
|
||||
|
||||
if (!product_info?.allow_items_not_in_stock && available_qty === 0) {
|
||||
item_add_to_cart = '';
|
||||
}
|
||||
|
||||
return `
|
||||
${item_found_status}
|
||||
${item_add_to_cart}
|
||||
@@ -257,12 +264,15 @@ class ItemConfigure {
|
||||
|
||||
btn_clear_values() {
|
||||
this.dialog.fields_list.forEach(f => {
|
||||
f.df.options = f.df.options.map(option => {
|
||||
option.disabled = false;
|
||||
return option;
|
||||
});
|
||||
if (f.df?.options) {
|
||||
f.df.options = f.df.options.map(option => {
|
||||
option.disabled = false;
|
||||
return option;
|
||||
});
|
||||
}
|
||||
});
|
||||
this.dialog.clear();
|
||||
this.dialog.$status_area.empty();
|
||||
this.on_attribute_selection();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user