Skip to content

Instantly share code, notes, and snippets.

@saidimu
Forked from mbrochh/gist:1055432
Created January 20, 2012 01:17
Show Gist options
  • Save saidimu/1644296 to your computer and use it in GitHub Desktop.
Save saidimu/1644296 to your computer and use it in GitHub Desktop.
Adding Tax to your cart
""" 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