Highlight SRP in red, if reg price is greater (in product view)
This commit is contained in:
parent
8f07f27a61
commit
0fbe3380cd
|
@ -487,7 +487,7 @@ class ProductsView(MasterView):
|
|||
if not text:
|
||||
return history
|
||||
|
||||
text = HTML.tag('span', c=text)
|
||||
text = HTML.tag('span', c=[text])
|
||||
br = HTML.tag('br')
|
||||
return HTML.tag('div', c=[text, br, history])
|
||||
|
||||
|
@ -506,6 +506,13 @@ class ProductsView(MasterView):
|
|||
else: # not buefy
|
||||
return self.add_price_history_link(text, 'regular')
|
||||
|
||||
def warn_if_regprice_more_than_srp(self, product, text):
|
||||
sugprice = product.suggested_price.price if product.suggested_price else None
|
||||
regprice = product.regular_price.price if product.regular_price else None
|
||||
if sugprice and regprice and sugprice > regprice:
|
||||
return HTML.tag('span', style='color: red;', c=text)
|
||||
return text
|
||||
|
||||
def render_suggested_price(self, product, column):
|
||||
text = self.render_price(product, column)
|
||||
|
||||
|
@ -515,6 +522,8 @@ class ProductsView(MasterView):
|
|||
date = localtime(self.rattail_config, history[0]['changed'], from_utc=True).date()
|
||||
text = "{} (as of {})".format(text, date)
|
||||
|
||||
text = self.warn_if_regprice_more_than_srp(product, text)
|
||||
|
||||
if self.get_use_buefy():
|
||||
# TODO: should add history link here too...
|
||||
return text
|
||||
|
@ -526,11 +535,7 @@ class ProductsView(MasterView):
|
|||
if not text:
|
||||
return ""
|
||||
|
||||
sugprice = product.suggested_price.price if product.suggested_price else None
|
||||
regprice = product.regular_price.price if product.regular_price else None
|
||||
if sugprice and regprice and sugprice < regprice:
|
||||
return HTML.tag('div', style='color: red;', c=text)
|
||||
|
||||
text = self.warn_if_regprice_more_than_srp(product, text)
|
||||
return text
|
||||
|
||||
def render_true_cost(self, product, field):
|
||||
|
|
Loading…
Reference in a new issue