Created
June 30, 2011 01:16
-
-
Save mbrochh/1055432 to your computer and use it in GitHub Desktop.
Adding Tax to your cart
This file contains 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
""" Cart modifierts for the myshop app of django-shop-adventures.""" | |
import decimal | |
from django.conf import settings | |
from shop.cart.cart_modifiers_base import BaseCartModifier | |
class FixedTaxRate(BaseCartModifier): | |
""" | |
This will add 19% of the subtotal of the order to the total. | |
It will also take all extra price fields into consideration and add 19% | |
to them as well. | |
""" | |
def process_cart(self, cart): | |
total = cart.subtotal_price | |
for item in cart.extra_price_fields: | |
total += item[1] | |
taxes = total * decimal.Decimal('0.19') | |
to_append = ('Taxes total', taxes) | |
cart.extra_price_fields.append(to_append) | |
return cart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment