Skip to content

Instantly share code, notes, and snippets.

@smoller
Created February 8, 2014 08:42
Show Gist options
  • Save smoller/9053a7358bc77e733838 to your computer and use it in GitHub Desktop.
Save smoller/9053a7358bc77e733838 to your computer and use it in GitHub Desktop.
class Product(ShopifyResource, mixins.Metafields, mixins.Events):
def price_range(self):
#prices is a list of unicode strings not floats
prices = [variant.price for variant in self.variants]
f = "%0.2f"
min_price = min(prices)
max_price = max(prices)
if min_price != max_price:
return "%s - %s" % (f % min_price, f % max_price)
else:
return f % min_price
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment