Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 0 additions & 80 deletions ls_shop/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
from erpnext.controllers.website_list_for_contact import get_transaction_list
from frappe import _
from frappe.translate import get_all_translations
from webshop.webshop.variant_selector.utils import (
get_attributes_and_values,
get_items_with_selected_attributes,
)

from ls_shop.utils import get_product_list

Expand All @@ -23,89 +19,13 @@ def wrapper(*args, **kwargs):
return wrapper


@frappe.whitelist(allow_guest=True)
def get_product_detail(item_code):
try:
website_item = frappe.get_doc("Website Item", {"name": item_code})
except Exception:
return {
"product": {
"id": "",
"brand": "",
"product_name": "",
"item_code": "",
"has_variants": "",
"description": "",
"website_image": "",
"website_image_alt": "",
"short_description": "",
"long_description": "",
"recommended_items": [],
"offers": "",
"slides": "",
"price_info": "",
"stock_qty": "",
}
}
context = frappe._dict({"route": website_item.route or website_item.make_route()})
context = website_item.get_context(context)
recommended_items = []
for item in website_item.get("recommended_items"):
recommended_website_item = frappe.get_doc("Website Item", {"name": item.get("website_item")})
recommended_item_context = frappe._dict(
{"route": recommended_website_item.route or recommended_website_item.make_route()}
)
recommended_item_context = recommended_website_item.get_context(recommended_item_context)
recommended_item_info = {
"id": recommended_website_item.get("name"),
"brand": recommended_website_item.get("brand") or recommended_website_item.get("item_group"),
"product_name": recommended_website_item.get("item_name")
or recommended_website_item.get("web_item_name"),
"item_code": recommended_website_item.get("item_code"),
"has_variants": recommended_website_item.get("has_variants"),
"description": recommended_website_item.get("description"),
"website_image": recommended_website_item.get("website_image"),
"website_image_alt": recommended_website_item.get("website_image_alt"),
"price_info": recommended_item_context.get("shopping_cart")
.get("product_info", {})
.get("price", {}),
}
recommended_items.append(recommended_item_info)
product = {
"id": website_item.get("name"),
"brand": website_item.get("brand") or website_item.get("item_group"),
"product_name": website_item.get("item_name") or website_item.get("web_item_name"),
"item_code": website_item.get("item_code"),
"has_variants": website_item.get("has_variants"),
"description": website_item.get("description"),
"website_image": website_item.get("website_image"),
"website_image_alt": website_item.get("website_image_alt"),
"short_description": website_item.get("web_short_description"),
"long_description": website_item.get("web_long_description"),
"recommended_items": recommended_items,
"offers": website_item.get("offers"),
"slides": context.get("slides"),
"price_info": context.get("shopping_cart").get("product_info", {}).get("price", {}),
"stock_qty": context.get("shopping_cart").get("product_info", {}).get("stock_qty", {}),
# "attributes": get_attributes_and_values()
}
product["attributes"] = get_attributes_and_values(product["product_name"])

return {"product": product}


@frappe.whitelist(allow_guest=True)
def get_order_detail(order_name):
sales_order = frappe.get_doc("Sales Order", order_name)

return {"sales_order": sales_order}


@frappe.whitelist(allow_guest=True)
def get_items_with_attributes(item_code, selected_attributes):
return get_items_with_selected_attributes(item_code, selected_attributes)


@frappe.whitelist()
def get_whitelist_transaction_list(
doctype,
Expand Down