def get_product_info_for_website(item_code): """get product price / stock info for website""" cart_quotation = _get_cart_quotation() cart_settings = get_shopping_cart_settings() price = get_price( item_code, cart_quotation.selling_price_list, cart_settings.default_customer_group, cart_settings.company ) stock_status = get_qty_in_stock(item_code, "website_warehouse") product_info = { "price": price, "stock_qty": stock_status.stock_qty, "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(), "sales_uom": frappe.db.get_value("Item", item_code, "sales_uom") } if product_info["price"]: if frappe.session.user != "Guest": item = cart_quotation.get({"item_code": item_code}) if item: product_info["qty"] = item[0].qty return { "product_info": product_info, "cart_settings": cart_settings }
def get_product_info(item_code): """get product price / stock info""" if not is_cart_enabled(): return {} qty = 0 cart_quotation = _get_cart_quotation() template_item_code = frappe.db.get_value("Item", item_code, "variant_of") stock_status = get_qty_in_stock(item_code, template_item_code) in_stock = stock_status.in_stock stock_qty = stock_status.stock_qty price = get_price(item_code, template_item_code, cart_quotation.selling_price_list) if price: price["formatted_price"] = fmt_money(price["price_list_rate"], currency=price["currency"]) price["currency"] = not cint(frappe.db.get_default("hide_currency_symbol")) \ and (frappe.db.get_value("Currency", price.currency, "symbol") or price.currency) \ or "" if frappe.session.user != "Guest": item = cart_quotation.get({"item_code": item_code}) if item: qty = item[0].qty return { "price": price, "stock_qty": stock_qty, "in_stock": in_stock, "uom": frappe.db.get_value("Item", item_code, "stock_uom"), "qty": qty, "show_stock_qty": show_quantity_in_website() }
def get_product_info(item_code): """get product price / stock info""" if not is_cart_enabled(): return {} qty = 0 cart_quotation = _get_cart_quotation() template_item_code = frappe.db.get_value("Item", item_code, "variant_of") stock_status = get_qty_in_stock(item_code, template_item_code) in_stock = stock_status.in_stock stock_qty = stock_status.stock_qty price = get_price(item_code, template_item_code, cart_quotation.selling_price_list) if price: price["formatted_price"] = fmt_money(price["price_list_rate"], currency=price["currency"]) price["currency"] = not cint(frappe.db.get_default("hide_currency_symbol")) \ and (frappe.db.get_value("Currency", price.currency, "symbol") or price.currency) \ or "" if frappe.session.user != "Guest": item = cart_quotation.get({"item_code": item_code}) if item: qty = item[0].qty return { "price": price, "stock_qty": stock_qty, "in_stock": in_stock, "uom": frappe.db.get_value("Item", item_code, "stock_uom"), "qty": qty, "show_stock_qty": show_quantity_in_website() }
def get_product_info_for_website(item_code): """get product price / stock info for website""" if not is_cart_enabled(): return {} cart_quotation = _get_cart_quotation() cart_settings = get_shopping_cart_settings() price = get_price( item_code, cart_quotation.selling_price_list, cart_settings.default_customer_group, cart_settings.company ) stock_status = get_qty_in_stock(item_code, "website_warehouse") product_info = { "price": price, "stock_qty": stock_status.stock_qty, "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 } if product_info["price"]: if frappe.session.user != "Guest": item = cart_quotation.get({"item_code": item_code}) if item: product_info["qty"] = item[0].qty return product_info
def get_product_info_for_website(item_code, skip_quotation_creation=False): """get product price / stock info for website""" cart_settings = get_shopping_cart_settings() if not cart_settings.enabled: return frappe._dict() cart_quotation = frappe._dict() if not skip_quotation_creation: cart_quotation = _get_cart_quotation() selling_price_list = cart_quotation.get( "selling_price_list") if cart_quotation else _set_price_list( cart_settings, None) price = get_price( item_code, #cart_quotation.selling_price_list, selling_price_list, cart_settings.default_customer_group, cart_settings.company) stock_status = get_qty_in_stock(item_code, "website_warehouse") product_info = { "price": price, "stock_qty": stock_status.stock_qty, "in_stock": stock_status.in_stock if stock_status.is_stock_item else get_non_stock_item_status(item_code, "website_warehouse"), "qty": 0, "uom": frappe.db.get_value("Item", item_code, "stock_uom"), "show_stock_qty": show_quantity_in_website(), "sales_uom": frappe.db.get_value("Item", item_code, "sales_uom") } if product_info["price"]: if frappe.session.user != "Guest": # item = cart_quotation.get({"item_code": item_code}) item = cart_quotation.get({"item_code": item_code }) if cart_quotation else None if item: product_info["qty"] = item[0].qty return frappe._dict({ "product_info": product_info, "cart_settings": cart_settings })
def get_product_info_for_website1(item_code): # custom implementation print(item_code,'--------------------------------------') print(""" = overriden get_product_info_for_website = """) # original cart_settings = get_shopping_cart_settings() if not cart_settings.enabled: return frappe._dict() cart_quotation = _get_cart_quotation() price = get_price( item_code, cart_quotation.selling_price_list, cart_settings.default_customer_group, cart_settings.company ) stock_status = get_qty_in_stock(item_code, "website_warehouse") product_info = { "price": price, "stock_qty": stock_status.stock_qty, "in_stock": stock_status.in_stock if stock_status.is_stock_item else 1, "qty": 0, "uom": "ll", "show_stock_qty": show_quantity_in_website(), "sales_uom": frappe.db.get_value("Item", item_code, "sales_uom"), "white_list":"ashish" } if product_info["price"]: if frappe.session.user != "Guest": item = cart_quotation.get({"item_code": item_code}) if item: product_info["qty"] = 99999999999 return frappe._dict({ "product_info": product_info, "cart_settings": cart_settings })