From 0dba507e1c0235b0513f749a12de176f43084d5a Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 24 Jan 2024 10:34:51 +0530 Subject: [PATCH] fix: not able to change address through portal --- .../templates/includes/cart/address_card.html | 79 ++++++++++++++++++- webshop/templates/pages/cart.js | 73 ----------------- 2 files changed, 78 insertions(+), 74 deletions(-) diff --git a/webshop/templates/includes/cart/address_card.html b/webshop/templates/includes/cart/address_card.html index 830ed649f5..fdcf0ac7c0 100644 --- a/webshop/templates/includes/cart/address_card.html +++ b/webshop/templates/includes/cart/address_card.html @@ -7,7 +7,7 @@
{{ address.display }}
- + @@ -15,3 +15,80 @@ + + + \ No newline at end of file diff --git a/webshop/templates/pages/cart.js b/webshop/templates/pages/cart.js index 83f734d29d..9e41add538 100644 --- a/webshop/templates/pages/cart.js +++ b/webshop/templates/pages/cart.js @@ -12,7 +12,6 @@ $.extend(shopping_cart, { }, bind_events: function() { - shopping_cart.bind_address_picker_dialog(); shopping_cart.bind_place_order(); shopping_cart.bind_request_quotation(); shopping_cart.bind_change_qty(); @@ -21,78 +20,6 @@ $.extend(shopping_cart, { shopping_cart.bind_coupon_code(); }, - bind_address_picker_dialog: function() { - const d = this.get_update_address_dialog(); - this.parent.find('.btn-change-address').on('click', (e) => { - const type = $(e.currentTarget).parents('.address-container').attr('data-address-type'); - $(d.get_field('address_picker').wrapper).html( - this.get_address_template(type) - ); - d.show(); - }); - }, - - get_update_address_dialog() { - let d = new frappe.ui.Dialog({ - title: "Select Address", - fields: [{ - 'fieldtype': 'HTML', - 'fieldname': 'address_picker', - }], - primary_action_label: __('Set Address'), - primary_action: () => { - const $card = d.$wrapper.find('.address-card.active'); - const address_type = $card.closest('[data-address-type]').attr('data-address-type'); - const address_name = $card.closest('[data-address-name]').attr('data-address-name'); - frappe.call({ - type: "POST", - method: "webshop.webshop.shopping_cart.cart.update_cart_address", - freeze: true, - args: { - address_type, - address_name - }, - callback: function(r) { - d.hide(); - if (!r.exc) { - $(".cart-tax-items").html(r.message.total); - shopping_cart.parent.find( - `.address-container[data-address-type="${address_type}"]` - ).html(r.message.address); - } - } - }); - } - }); - - return d; - }, - - get_address_template(type) { - return { - shipping: `
-
- {% for address in shipping_addresses %} -
- {% include "templates/includes/cart/address_picker_card.html" %} -
- {% endfor %} -
-
`, - billing: `
-
- {% for address in billing_addresses %} -
- {% include "templates/includes/cart/address_picker_card.html" %} -
- {% endfor %} -
-
`, - }[type]; - }, - bind_place_order: function() { $(".btn-place-order").on("click", function() { shopping_cart.place_order(this);