[fix] Add to Cart visibility, Customer's Price List in Shopping Cart and Address creation from Shopping Cart
This commit is contained in:
parent
cf26964deb
commit
e6f7ac961f
3
erpnext/change_log/current/shopping_cart.md
Normal file
3
erpnext/change_log/current/shopping_cart.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
- Fixed inconsistent visibility of 'Add to Cart' button
|
||||||
|
- Use Customer's Price List in Shopping Cart if found
|
||||||
|
- Fixed Address creation from Shopping Cart
|
@ -7,6 +7,7 @@ from frappe import throw, _
|
|||||||
import frappe.defaults
|
import frappe.defaults
|
||||||
from frappe.utils import cint, flt, get_fullname, fmt_money, cstr
|
from frappe.utils import cint, flt, get_fullname, fmt_money, cstr
|
||||||
from erpnext.utilities.doctype.address.address import get_address_display
|
from erpnext.utilities.doctype.address.address import get_address_display
|
||||||
|
from erpnext.shopping_cart.doctype.shopping_cart_settings.shopping_cart_settings import get_shopping_cart_settings
|
||||||
from frappe.utils.nestedset import get_root_of
|
from frappe.utils.nestedset import get_root_of
|
||||||
|
|
||||||
class WebsitePriceListMissingError(frappe.ValidationError): pass
|
class WebsitePriceListMissingError(frappe.ValidationError): pass
|
||||||
@ -162,7 +163,7 @@ def _get_cart_quotation(party=None):
|
|||||||
else:
|
else:
|
||||||
qdoc = frappe.get_doc({
|
qdoc = frappe.get_doc({
|
||||||
"doctype": "Quotation",
|
"doctype": "Quotation",
|
||||||
"naming_series": frappe.defaults.get_user_default("shopping_cart_quotation_series") or "QTN-CART-",
|
"naming_series": get_shopping_cart_settings().quotation_series or "QTN-CART-",
|
||||||
"quotation_to": party.doctype,
|
"quotation_to": party.doctype,
|
||||||
"company": frappe.db.get_value("Shopping Cart Settings", None, "company"),
|
"company": frappe.db.get_value("Shopping Cart Settings", None, "company"),
|
||||||
"order_type": "Shopping Cart",
|
"order_type": "Shopping Cart",
|
||||||
@ -236,7 +237,9 @@ def apply_cart_settings(party=None, quotation=None):
|
|||||||
|
|
||||||
def set_price_list_and_rate(quotation, cart_settings, billing_territory):
|
def set_price_list_and_rate(quotation, cart_settings, billing_territory):
|
||||||
"""set price list based on billing territory"""
|
"""set price list based on billing territory"""
|
||||||
quotation.selling_price_list = cart_settings.get_price_list(billing_territory)
|
|
||||||
|
_set_price_list(quotation, cart_settings, billing_territory)
|
||||||
|
|
||||||
# reset values
|
# reset values
|
||||||
quotation.price_list_currency = quotation.currency = \
|
quotation.price_list_currency = quotation.currency = \
|
||||||
quotation.plc_conversion_rate = quotation.conversion_rate = None
|
quotation.plc_conversion_rate = quotation.conversion_rate = None
|
||||||
@ -249,6 +252,18 @@ def set_price_list_and_rate(quotation, cart_settings, billing_territory):
|
|||||||
# set it in cookies for using in product page
|
# set it in cookies for using in product page
|
||||||
frappe.local.cookie_manager.set_cookie("selling_price_list", quotation.selling_price_list)
|
frappe.local.cookie_manager.set_cookie("selling_price_list", quotation.selling_price_list)
|
||||||
|
|
||||||
|
def _set_price_list(quotation, cart_settings, billing_territory):
|
||||||
|
# check if customer price list exists
|
||||||
|
selling_price_list = None
|
||||||
|
if quotation.customer:
|
||||||
|
selling_price_list = frappe.db.get_value("Customer", quotation.customer, "default_price_list")
|
||||||
|
|
||||||
|
# else check for territory based price list
|
||||||
|
if not selling_price_list:
|
||||||
|
selling_price_list = cart_settings.get_price_list(billing_territory)
|
||||||
|
|
||||||
|
quotation.selling_price_list = selling_price_list
|
||||||
|
|
||||||
def set_taxes(quotation, cart_settings, billing_territory):
|
def set_taxes(quotation, cart_settings, billing_territory):
|
||||||
"""set taxes based on billing territory"""
|
"""set taxes based on billing territory"""
|
||||||
quotation.taxes_and_charges = cart_settings.get_tax_master(billing_territory)
|
quotation.taxes_and_charges = cart_settings.get_tax_master(billing_territory)
|
||||||
|
@ -23,10 +23,6 @@ class ShoppingCartSettings(Document):
|
|||||||
self.validate_tax_masters()
|
self.validate_tax_masters()
|
||||||
self.validate_exchange_rates_exist()
|
self.validate_exchange_rates_exist()
|
||||||
|
|
||||||
def on_update(self):
|
|
||||||
frappe.db.set_default("shopping_cart_enabled", self.get("enabled") or 0)
|
|
||||||
frappe.db.set_default("shopping_cart_quotation_series", self.get("quotation_series"))
|
|
||||||
|
|
||||||
def validate_overlapping_territories(self, parentfield, fieldname):
|
def validate_overlapping_territories(self, parentfield, fieldname):
|
||||||
# for displaying message
|
# for displaying message
|
||||||
doctype = self.meta.get_field(parentfield).options
|
doctype = self.meta.get_field(parentfield).options
|
||||||
|
@ -4,19 +4,19 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import cint, fmt_money, cstr
|
from frappe.utils import cint, fmt_money
|
||||||
from erpnext.shopping_cart.cart import _get_cart_quotation
|
from erpnext.shopping_cart.cart import _get_cart_quotation
|
||||||
from urllib import unquote
|
from erpnext.shopping_cart.doctype.shopping_cart_settings.shopping_cart_settings import is_cart_enabled
|
||||||
|
|
||||||
@frappe.whitelist(allow_guest=True)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def get_product_info(item_code):
|
def get_product_info(item_code):
|
||||||
"""get product price / stock info"""
|
"""get product price / stock info"""
|
||||||
if not cint(frappe.db.get_default("shopping_cart_enabled")):
|
if not is_cart_enabled():
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
cart_quotation = _get_cart_quotation()
|
cart_quotation = _get_cart_quotation()
|
||||||
|
|
||||||
price_list = cstr(unquote(frappe.local.request.cookies.get("selling_price_list")))
|
price_list = cart_quotation.selling_price_list
|
||||||
|
|
||||||
warehouse = frappe.db.get_value("Item", item_code, "website_warehouse")
|
warehouse = frappe.db.get_value("Item", item_code, "website_warehouse")
|
||||||
if warehouse:
|
if warehouse:
|
||||||
|
@ -9,7 +9,7 @@ import frappe.defaults
|
|||||||
from erpnext.shopping_cart.doctype.shopping_cart_settings.shopping_cart_settings import is_cart_enabled
|
from erpnext.shopping_cart.doctype.shopping_cart_settings.shopping_cart_settings import is_cart_enabled
|
||||||
|
|
||||||
def show_cart_count():
|
def show_cart_count():
|
||||||
if (frappe.db.get_default("shopping_cart_enabled") and
|
if (is_cart_enabled() and
|
||||||
frappe.db.get_value("User", frappe.session.user, "user_type") == "Website User"):
|
frappe.db.get_value("User", frappe.session.user, "user_type") == "Website User"):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -32,11 +32,11 @@ $.extend(shopping_cart, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#cart-add-shipping-address").on("click", function() {
|
$("#cart-add-shipping-address").on("click", function() {
|
||||||
window.location.href = "address?address_fieldname=shipping_address_name";
|
window.location.href = "addresses";
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#cart-add-billing-address").on("click", function() {
|
$("#cart-add-billing-address").on("click", function() {
|
||||||
window.location.href = "address?address_fieldname=customer_address";
|
window.location.href = "address";
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".btn-place-order").on("click", function() {
|
$(".btn-place-order").on("click", function() {
|
||||||
|
@ -35,14 +35,14 @@
|
|||||||
<div id="cart-shipping-address" class="panel-group"
|
<div id="cart-shipping-address" class="panel-group"
|
||||||
data-fieldname="shipping_address_name"></div>
|
data-fieldname="shipping_address_name"></div>
|
||||||
<button class="btn btn-default" type="button" id="cart-add-shipping-address">
|
<button class="btn btn-default" type="button" id="cart-add-shipping-address">
|
||||||
<span class="icon icon-plus"></span> {{ _("New Shipping Address") }}</button>
|
<span class="icon icon-list"></span> {{ _("Manage Addresses") }}</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<h4>Billing Address</h4>
|
<h4>Billing Address</h4>
|
||||||
<div id="cart-billing-address" class="panel-group"
|
<div id="cart-billing-address" class="panel-group"
|
||||||
data-fieldname="customer_address"></div>
|
data-fieldname="customer_address"></div>
|
||||||
<button class="btn btn-default" type="button" id="cart-add-billing-address">
|
<button class="btn btn-default" type="button" id="cart-add-billing-address">
|
||||||
<span class="icon icon-plus"></span> {{ _("New Billing Address") }}</button>
|
<span class="icon icon-list"></span> {{ _("Manage Addresses") }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user