`);
}
render_item_sub_categories(categories) {
- if (categories) {
+ if (categories && categories.length) {
let sub_group_html = `
${ __('Sub Categories') }
diff --git a/erpnext/public/js/shopping_cart.js b/erpnext/public/js/shopping_cart.js
index 331d04eb43..80f731e51c 100644
--- a/erpnext/public/js/shopping_cart.js
+++ b/erpnext/public/js/shopping_cart.js
@@ -54,7 +54,6 @@ frappe.ready(function() {
// update login
shopping_cart.show_shoppingcart_dropdown();
shopping_cart.set_cart_count();
- shopping_cart.bind_dropdown_cart_buttons();
shopping_cart.show_cart_navbar();
});
@@ -75,7 +74,7 @@ $.extend(shopping_cart, {
},
update_cart: function(opts) {
- if(frappe.session.user==="Guest") {
+ if (frappe.session.user==="Guest") {
if(localStorage) {
localStorage.setItem("last_visited", window.location.pathname);
}
@@ -156,29 +155,6 @@ $.extend(shopping_cart, {
});
},
-
- bind_dropdown_cart_buttons: function () {
- $(".cart-icon").on('click', '.number-spinner button', function () {
- var btn = $(this),
- input = btn.closest('.number-spinner').find('input'),
- oldValue = input.val().trim(),
- newVal = 0;
-
- if (btn.attr('data-dir') == 'up') {
- newVal = parseInt(oldValue) + 1;
- } else {
- if (oldValue > 1) {
- newVal = parseInt(oldValue) - 1;
- }
- }
- input.val(newVal);
- var item_code = input.attr("data-item-code");
- shopping_cart.shopping_cart_update({item_code, qty: newVal, cart_dropdown: true});
- return false;
- });
-
- },
-
show_cart_navbar: function () {
frappe.call({
method: "erpnext.e_commerce.doctype.e_commerce_settings.e_commerce_settings.is_cart_enabled",
diff --git a/erpnext/public/js/wishlist.js b/erpnext/public/js/wishlist.js
index 11dae355cb..1c5bee681f 100644
--- a/erpnext/public/js/wishlist.js
+++ b/erpnext/public/js/wishlist.js
@@ -58,6 +58,8 @@ $.extend(wishlist, {
bind_remove_action: function() {
// remove item from wishlist
+ let me = this;
+
$('.page_content').on("click", ".remove-wish", (e) => {
const $remove_wish_btn = $(e.currentTarget);
let item_code = $remove_wish_btn.data("item-code");
@@ -65,6 +67,10 @@ $.extend(wishlist, {
let success_action = function() {
const $card_wrapper = $remove_wish_btn.closest(".wishlist-card");
$card_wrapper.addClass("wish-removed");
+ if (frappe.get_cookie("wish_count") == 0) {
+ $(".page_content").empty();
+ me.render_empty_state();
+ }
};
let args = { item_code: item_code };
this.add_remove_from_wishlist("remove", args, success_action);
@@ -78,6 +84,14 @@ $.extend(wishlist, {
const $wish_icon = $btn.find('.wish-icon');
let me = this;
+ if(frappe.session.user==="Guest") {
+ if(localStorage) {
+ localStorage.setItem("last_visited", window.location.pathname);
+ }
+ window.location.href = "/login";
+ return;
+ }
+
let success_action = function() {
e_commerce.wishlist.set_wishlist_count();
};
@@ -122,30 +136,48 @@ $.extend(wishlist, {
success_action: method to execute on successs,
failure_action: method to execute on failure,
async: make call asynchronously (true/false). */
- let method = "erpnext.e_commerce.doctype.wishlist.wishlist.add_to_wishlist";
- if (action === "remove") {
- method = "erpnext.e_commerce.doctype.wishlist.wishlist.remove_from_wishlist";
- }
-
- frappe.call({
- async: async,
- type: "POST",
- method: method,
- args: args,
- callback: function (r) {
- if (r.exc) {
- if (failure_action && (typeof failure_action === 'function')) {
- failure_action();
- }
- frappe.msgprint({
- message: __("Sorry, something went wrong. Please refresh."),
- indicator: "red", title: __("Note")
- });
- } else if (success_action && (typeof success_action === 'function')) {
- success_action();
- }
+ if (frappe.session.user==="Guest") {
+ if(localStorage) {
+ localStorage.setItem("last_visited", window.location.pathname);
}
- });
+ window.location.href = "/login";
+ } else {
+ let method = "erpnext.e_commerce.doctype.wishlist.wishlist.add_to_wishlist";
+ if (action === "remove") {
+ method = "erpnext.e_commerce.doctype.wishlist.wishlist.remove_from_wishlist";
+ }
+
+ frappe.call({
+ async: async,
+ type: "POST",
+ method: method,
+ args: args,
+ callback: function (r) {
+ if (r.exc) {
+ if (failure_action && (typeof failure_action === 'function')) {
+ failure_action();
+ }
+ frappe.msgprint({
+ message: __("Sorry, something went wrong. Please refresh."),
+ indicator: "red", title: __("Note")
+ });
+ } else if (success_action && (typeof success_action === 'function')) {
+ success_action();
+ }
+ }
+ });
+ }
+ },
+
+ render_empty_state() {
+ $(".page_content").append(`
+
+
+

+
+
${ __('Wishlist is empty !') }
+
+ `);
}
});
diff --git a/erpnext/templates/generators/item/item_reviews.html b/erpnext/templates/generators/item/item_reviews.html
index fd03a823af..cd38bf3b14 100644
--- a/erpnext/templates/generators/item/item_reviews.html
+++ b/erpnext/templates/generators/item/item_reviews.html
@@ -5,11 +5,11 @@
{{ ratings_summary(reviews, reviews_per_rating, average_rating, average_whole_rating) }}
- {% if frappe.session.user != "Guest" %}
-
+ {% if frappe.session.user != "Guest" and user_is_customer %}
+
{% endif %}
diff --git a/erpnext/templates/includes/cart.js b/erpnext/templates/includes/cart.js
index f2b026c866..f0781ab68f 100644
--- a/erpnext/templates/includes/cart.js
+++ b/erpnext/templates/includes/cart.js
@@ -19,7 +19,6 @@ $.extend(shopping_cart, {
shopping_cart.bind_request_quotation();
shopping_cart.bind_change_qty();
shopping_cart.bind_change_notes();
- shopping_cart.bind_dropdown_cart_buttons();
shopping_cart.bind_coupon_code();
},
@@ -129,8 +128,14 @@ $.extend(shopping_cart, {
}
}
input.val(newVal);
+
+ let notes = input.closest("td").siblings().find(".notes").text().trim();
var item_code = input.attr("data-item-code");
- shopping_cart.shopping_cart_update({item_code, qty: newVal});
+ shopping_cart.shopping_cart_update({
+ item_code,
+ qty: newVal,
+ additional_notes: notes
+ });
});
},
diff --git a/erpnext/templates/includes/cart/cart_items.html b/erpnext/templates/includes/cart/cart_items.html
index 75441c42bc..d534b8fd7c 100644
--- a/erpnext/templates/includes/cart/cart_items.html
+++ b/erpnext/templates/includes/cart/cart_items.html
@@ -13,7 +13,7 @@
{{ _('Variant of') }}
{{ variant_of }}
{% endif %}
-
+
diff --git a/erpnext/templates/pages/wishlist.html b/erpnext/templates/pages/wishlist.html
index 4c039e3c1d..7a81dedb49 100644
--- a/erpnext/templates/pages/wishlist.html
+++ b/erpnext/templates/pages/wishlist.html
@@ -17,8 +17,12 @@