marination | c842305 | 2021-04-07 23:49:04 +0530 | [diff] [blame] | 1 | # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors |
| 2 | # License: GNU General Public License v3. See license.txt |
marination | c842305 | 2021-04-07 23:49:04 +0530 | [diff] [blame] | 3 | import frappe |
marination | 9fb61ef | 2022-02-01 00:39:14 +0530 | [diff] [blame] | 4 | |
| 5 | from erpnext.e_commerce.doctype.e_commerce_settings.e_commerce_settings import ( |
| 6 | get_shopping_cart_settings, |
| 7 | ) |
marination | c842305 | 2021-04-07 23:49:04 +0530 | [diff] [blame] | 8 | from erpnext.e_commerce.doctype.item_review.item_review import get_item_reviews |
marination | 2fec068 | 2021-07-13 23:46:24 +0530 | [diff] [blame] | 9 | from erpnext.e_commerce.doctype.website_item.website_item import check_if_user_is_customer |
marination | 9fb61ef | 2022-02-01 00:39:14 +0530 | [diff] [blame] | 10 | |
marination | c842305 | 2021-04-07 23:49:04 +0530 | [diff] [blame] | 11 | |
| 12 | def get_context(context): |
marination | 45f64bd | 2021-09-01 14:57:50 +0530 | [diff] [blame] | 13 | context.body_class = "product-page" |
marination | b29c5d6 | 2021-05-25 01:35:22 +0530 | [diff] [blame] | 14 | context.no_cache = 1 |
marination | c842305 | 2021-04-07 23:49:04 +0530 | [diff] [blame] | 15 | context.full_page = True |
| 16 | context.reviews = None |
marination | b29c5d6 | 2021-05-25 01:35:22 +0530 | [diff] [blame] | 17 | |
marination | 6b2b9dc | 2021-08-25 13:09:35 +0530 | [diff] [blame] | 18 | if frappe.form_dict and frappe.form_dict.get("web_item"): |
| 19 | context.web_item = frappe.form_dict.get("web_item") |
marination | 2fec068 | 2021-07-13 23:46:24 +0530 | [diff] [blame] | 20 | context.user_is_customer = check_if_user_is_customer() |
marination | b4529b8 | 2021-08-09 21:00:31 +0530 | [diff] [blame] | 21 | context.enable_reviews = get_shopping_cart_settings().enable_reviews |
marination | 45f64bd | 2021-09-01 14:57:50 +0530 | [diff] [blame] | 22 | |
marination | b4529b8 | 2021-08-09 21:00:31 +0530 | [diff] [blame] | 23 | if context.enable_reviews: |
marination | 6b2b9dc | 2021-08-25 13:09:35 +0530 | [diff] [blame] | 24 | reviews_data = get_item_reviews(context.web_item) |
| 25 | context.update(reviews_data) |