mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 16:34:46 +00:00
Merge pull request #24093 from prssanna/item-configurator-fix-version-12
fix: allow add to cart for any item if allow_items_not_in_stock is enabled
This commit is contained in:
0
FETCH_HEAD
Normal file
0
FETCH_HEAD
Normal file
@@ -249,6 +249,7 @@ def get_next_attribute_and_values(item_code, selected_attributes):
|
|||||||
|
|
||||||
optional_attributes = item_cache.get_optional_attributes()
|
optional_attributes = item_cache.get_optional_attributes()
|
||||||
exact_match = []
|
exact_match = []
|
||||||
|
allow_items_not_in_stock = False
|
||||||
# search for exact match if all selected attributes are required attributes
|
# search for exact match if all selected attributes are required attributes
|
||||||
if len(selected_attributes.keys()) >= (len(attribute_list) - len(optional_attributes)):
|
if len(selected_attributes.keys()) >= (len(attribute_list) - len(optional_attributes)):
|
||||||
item_attribute_value_map = item_cache.get_item_attribute_value_map()
|
item_attribute_value_map = item_cache.get_item_attribute_value_map()
|
||||||
@@ -263,10 +264,7 @@ def get_next_attribute_and_values(item_code, selected_attributes):
|
|||||||
if exact_match:
|
if exact_match:
|
||||||
data = get_product_info_for_website(exact_match[0])
|
data = get_product_info_for_website(exact_match[0])
|
||||||
product_info = data.product_info
|
product_info = data.product_info
|
||||||
|
allow_items_not_in_stock = cint(data.cart_settings.allow_items_not_in_stock)
|
||||||
if product_info:
|
|
||||||
product_info["allow_items_not_in_stock"] = cint(data.cart_settings.allow_items_not_in_stock)
|
|
||||||
|
|
||||||
if not data.cart_settings.show_price:
|
if not data.cart_settings.show_price:
|
||||||
product_info = None
|
product_info = None
|
||||||
else:
|
else:
|
||||||
@@ -278,6 +276,7 @@ def get_next_attribute_and_values(item_code, selected_attributes):
|
|||||||
'filtered_items_count': filtered_items_count,
|
'filtered_items_count': filtered_items_count,
|
||||||
'filtered_items': filtered_items if filtered_items_count < 10 else [],
|
'filtered_items': filtered_items if filtered_items_count < 10 else [],
|
||||||
'exact_match': exact_match,
|
'exact_match': exact_match,
|
||||||
|
'allow_items_not_in_stock': allow_items_not_in_stock,
|
||||||
'product_info': product_info
|
'product_info': product_info
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ class ItemConfigure {
|
|||||||
this.dialog.$status_area.empty();
|
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, allow_items_not_in_stock }) {
|
||||||
const exact_match_message = __('1 exact match.');
|
const exact_match_message = __('1 exact match.');
|
||||||
const one_item = exact_match.length === 1 ?
|
const one_item = exact_match.length === 1 ?
|
||||||
exact_match[0] :
|
exact_match[0] :
|
||||||
@@ -194,16 +194,9 @@ class ItemConfigure {
|
|||||||
filtered_items[0] : '';
|
filtered_items[0] : '';
|
||||||
|
|
||||||
// Allow Add to Cart if adding out of stock items enabled in Shopping Cart else check stock.
|
// Allow Add to Cart if adding out of stock items enabled in Shopping Cart else check stock.
|
||||||
var in_stock;
|
const in_stock = allow_items_not_in_stock ? 1 : product_info && product_info.in_stock;
|
||||||
var add_to_cart;
|
const add_to_cart = `<a href data-action="btn_add_to_cart" data-item-code="${one_item}">${__('Add to cart')}</a>`;
|
||||||
var product_action;
|
const product_action = in_stock ? add_to_cart : `<a style="color:#74808b;">${__('Not in Stock')}</a>`;
|
||||||
if (product_info) {
|
|
||||||
in_stock = product_info.allow_items_not_in_stock ? 1 : product_info.in_stock;
|
|
||||||
add_to_cart = `<a href data-action="btn_add_to_cart" data-item-code="${one_item}">${__('Add to cart')}</a>`;
|
|
||||||
product_action = in_stock ? add_to_cart : `<a style="color:#74808b;">${__('Not in Stock')}</a>`;
|
|
||||||
} else {
|
|
||||||
product_info = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
const item_add_to_cart = one_item ? `
|
const item_add_to_cart = one_item ? `
|
||||||
<div class="alert alert-success d-flex justify-content-between align-items-center" role="alert">
|
<div class="alert alert-success d-flex justify-content-between align-items-center" role="alert">
|
||||||
|
|||||||
Reference in New Issue
Block a user