fix: Handle unavailable Variants in Website (#22195)
* fix: Handle unavailable Variants in Website * fix: Fetch cart setting from argument
This commit is contained in:
parent
d8683d381b
commit
2112834743
@ -1,4 +1,5 @@
|
|||||||
import frappe
|
import frappe
|
||||||
|
from frappe.utils import cint
|
||||||
from erpnext.portal.product_configurator.item_variants_cache import ItemVariantsCacheManager
|
from erpnext.portal.product_configurator.item_variants_cache import ItemVariantsCacheManager
|
||||||
|
|
||||||
def get_field_filter_data():
|
def get_field_filter_data():
|
||||||
@ -243,6 +244,8 @@ def get_next_attribute_and_values(item_code, selected_attributes):
|
|||||||
else:
|
else:
|
||||||
product_info = None
|
product_info = None
|
||||||
|
|
||||||
|
product_info["allow_items_not_in_stock"] = cint(data.cart_settings.allow_items_not_in_stock)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'next_attribute': next_attribute,
|
'next_attribute': next_attribute,
|
||||||
'valid_options_for_attributes': valid_options_for_attributes,
|
'valid_options_for_attributes': valid_options_for_attributes,
|
||||||
|
@ -78,8 +78,10 @@ def place_order():
|
|||||||
|
|
||||||
if is_stock_item:
|
if is_stock_item:
|
||||||
item_stock = get_qty_in_stock(item.item_code, "website_warehouse")
|
item_stock = get_qty_in_stock(item.item_code, "website_warehouse")
|
||||||
|
if not cint(item_stock.in_stock):
|
||||||
|
throw(_("{1} Not in Stock").format(item.item_code))
|
||||||
if item.qty > item_stock.stock_qty[0][0]:
|
if item.qty > item_stock.stock_qty[0][0]:
|
||||||
throw(_("Only {0} in stock for item {1}").format(item_stock.stock_qty[0][0], item.item_code))
|
throw(_("Only {0} in Stock for item {1}").format(item_stock.stock_qty[0][0], item.item_code))
|
||||||
|
|
||||||
sales_order.flags.ignore_permissions = True
|
sales_order.flags.ignore_permissions = True
|
||||||
sales_order.insert()
|
sales_order.insert()
|
||||||
|
@ -193,14 +193,17 @@ class ItemConfigure {
|
|||||||
filtered_items_count === 1 ?
|
filtered_items_count === 1 ?
|
||||||
filtered_items[0] : '';
|
filtered_items[0] : '';
|
||||||
|
|
||||||
|
// Allow Add to Cart if adding out of stock items enabled in Shopping Cart else check stock.
|
||||||
|
const in_stock = product_info.allow_items_not_in_stock ? 1 : product_info.in_stock;
|
||||||
|
const add_to_cart = `<a href data-action="btn_add_to_cart" data-item-code="${one_item}">${__('Add to cart')}</a>`;
|
||||||
|
const product_action = in_stock ? add_to_cart : `<a style="color:#74808b;">${__('Not in Stock')}</a>`;
|
||||||
|
|
||||||
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">
|
||||||
<div>
|
<div>
|
||||||
<div>${one_item} ${product_info && product_info.price ? '(' + product_info.price.formatted_price_sales_uom + ')' : ''}</div>
|
<div>${one_item} ${product_info && product_info.price ? '(' + product_info.price.formatted_price_sales_uom + ')' : ''}</div>
|
||||||
</div>
|
</div>
|
||||||
<a href data-action="btn_add_to_cart" data-item-code="${one_item}">
|
${product_action}
|
||||||
${__('Add to cart')}
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
`: '';
|
`: '';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user