diff --git a/rattail/products.py b/rattail/products.py index a260e219eb9af2ad79416d61a422d37714e43c7b..9b50edc483458a29d8ce3f27b91e6848c7497e14 100644 --- a/rattail/products.py +++ b/rattail/products.py @@ -59,6 +59,35 @@ class ProductsHandler(GenericHandler): if upc: return pod.get_image_url(self.config, upc) + def render_price(self, price, html=False, **kwargs): + """ + Render the given ``price`` object as text. + + :returns: String containing the rendered price, or ``None`` if + nothing was applicable. + """ + if price.price is not None and price.pack_price is not None: + if price.multiple > 1: + return "{} / {} ({} / {})".format( + self.app.render_currency(price.price), + price.multiple, + self.app.render_currency(price.pack_price), + price.pack_multiple) + return "{} ({} / {})".format( + self.app.render_currency(price.price), + self.app.render_currency(price.pack_price), + price.pack_multiple) + if price.price is not None: + if price.multiple is not None and price.multiple > 1: + return "{} / {}".format( + self.app.render_currency(price.price), + price.multiple) + return self.app.render_currency(price.price) + if price.pack_price is not None: + return "{} / {}".format( + self.app.render_currency(price.pack_price), + price.pack_multiple) + def get_uom_sil_codes(self, session, uppercase=False, **kwargs): """ This should return a dict, keys of which are UOM abbreviation strings,