Skip to content

Instantly share code, notes, and snippets.

@g33klord
Created June 16, 2014 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save g33klord/fd37e488eb0ab95f2c14 to your computer and use it in GitHub Desktop.
Save g33klord/fd37e488eb0ab95f2c14 to your computer and use it in GitHub Desktop.
try:
attr_id = items['item']['attr_id']
attribute = Attribute.objects.get(productid=prods.id,id=attr_id)
total_order += attribute.unit_price * int(quantity)
items[item]['price'] = attribute.unit_price
except Attribute.DoesNotExist:
total_order += prods.price * int(quantity)
items[item]['price'] = prods.price
except TypeError:
attr_id = items['item']['attr_id']
attribute = Attribute.objects.get(productid=prods.id,id=attr_id)
items['attribute'] = attribute.label+attribute.value+attribute+unit
total_order += prods.price * int(quantity)
items[item]['price'] = prods.price
finally :
total_order += prods.price * int(quantity)
items[item]['price'] = prods.price
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment