Created
March 4, 2013 18:15
-
-
Save shofetim/5084226 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def _price(product, level): | |
| if product.is_priced_by_weight: | |
| price_obj = product.sell_price_per_pound(level) | |
| else: | |
| price_obj = product.sell_price(level) | |
| amount, off = price_obj | |
| if off == False: | |
| off = "" | |
| try: | |
| amount = float(amount) | |
| if amount: | |
| if product.is_priced_by_weight: | |
| price = "$%s per lb." % intcomma(floatformat(amount,2)) | |
| else: | |
| price = "$%s" % intcomma(floatformat(amount,2)) | |
| if amount > 0 and off != "": | |
| return "<nobr>%s %s%% off</nobr>" % (price, off) | |
| elif amount > 0: | |
| return price | |
| else: | |
| return "<span class='negative_amount'>%s</span>" % price | |
| except: | |
| print "Couldn't get price for %s" % [product] | |
| return "$0.00" | |
| def current_users_price(product, customer=False): | |
| price_level = customer.price_level if customer else RETAIL | |
| if product.is_priced_by_weight: | |
| price_obj = product.sell_price_per_pound(price_level) | |
| else: | |
| price_obj = product.sell_price(price_level) | |
| amount, off = price_obj | |
| if off == False: | |
| off = "" | |
| try: | |
| amount = float(amount) | |
| if amount: | |
| if product.is_priced_by_weight: | |
| price = "$%s per lb." % intcomma(floatformat(amount,2)) | |
| else: | |
| price = "$%s" % intcomma(floatformat(amount,2)) | |
| if amount > 0 and off != "": | |
| return mark_safe("<nobr>%s %s%% off</nobr>" % (price, off)) | |
| elif amount > 0: | |
| return price | |
| else: | |
| return mark_safe("<span class='negative_amount'>%s</span>" % price) | |
| except: | |
| pass | |
| return "$0.00" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment