[fix] honour the shopping cart setting when showing the stock and non-stock item (#13988)
diff --git a/erpnext/shopping_cart/product_info.py b/erpnext/shopping_cart/product_info.py
index 33cac17..e62d633 100644
--- a/erpnext/shopping_cart/product_info.py
+++ b/erpnext/shopping_cart/product_info.py
@@ -33,7 +33,7 @@
"in_stock": stock_status.in_stock if stock_status.is_stock_item else 1,
"qty": 0,
"uom": frappe.db.get_value("Item", item_code, "stock_uom"),
- "show_stock_qty": show_quantity_in_website() if stock_status.is_stock_item else 0,
+ "show_stock_qty": show_quantity_in_website(),
"sales_uom": frappe.db.get_value("Item", item_code, "sales_uom")
}
@@ -50,6 +50,7 @@
product_info = get_product_info_for_website(item.item_code)
if product_info:
+ item.update(product_info)
item["stock_uom"] = product_info.get("uom")
item["sales_uom"] = product_info.get("sales_uom")
if product_info.get("price"):
diff --git a/erpnext/templates/includes/products_as_grid.html b/erpnext/templates/includes/products_as_grid.html
index 34c2ccd..a057f5d 100644
--- a/erpnext/templates/includes/products_as_grid.html
+++ b/erpnext/templates/includes/products_as_grid.html
@@ -12,10 +12,12 @@
<div> </div>
<div style='font-size: small; margin-bottom: 10px;'> </div>
{% endif %}
- {% if in_stock or not is_stock_item %}
- <div style='color: green'> <i class='fa fa-check'></i> {{ _("In stock") }}</div>
- {% else %}
- <div style='color: red'> <i class='fa fa-close'></i> {{ _("Not in stock") }}</div>
+ {% if show_stock_qty %}
+ {% if in_stock %}
+ <div style='color: green'> <i class='fa fa-check'></i> {{ _("In stock") }}</div>
+ {% else %}
+ <div style='color: red'> <i class='fa fa-close'></i> {{ _("Not in stock") }}</div>
+ {% endif %}
{% endif %}
</div>
</div>