Site Sections: Satchmo Main | Wiki | Demo Store |

Changeset 1768

Show
Ignore:
Timestamp:
12/04/2008 04:12:27 PM (7 months ago)
Author:
bkroeze
Message:

Solidifying discount handling and enhanced configurable products so that sale prices are available when changing options

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • satchmo/trunk/satchmo/discount/templatetags/satchmo_discounts.py

    r1234 r1768  
    88from django.template import Context, Template 
    99from django.utils.translation import get_language, ugettext_lazy as _ 
     10from satchmo.configuration import config_value 
    1011from satchmo.discount.utils import calc_by_percentage, find_best_auto_discount 
    11 from satchmo.configuration import config_value 
    1212from satchmo.shop.templatetags import get_filter_args 
     13from satchmo.tax.templatetags import satchmo_tax 
     14import logging 
     15 
     16log = logging.getLogger('discount') 
    1317 
    1418register = template.Library() 
    1519 
    1620def sale_price(product): 
     21    """Returns the sale price, including tax if that is the default.""" 
     22    if config_value('TAX', 'DEFAULT_VIEW_TAX'): 
     23        return taxed_sale_price(product) 
     24    else: 
     25        return untaxed_sale_price(product) 
     26 
     27register.filter('sale_price', sale_price) 
     28 
     29def untaxed_sale_price(product): 
    1730    """Returns the product unit price with the best auto discount applied.""" 
    18     disc = find_best_auto_discount(product) 
     31    discount = find_best_auto_discount(product) 
    1932    price = product.unit_price 
    20     if disc: 
    21         return calc_by_percentage(price, disc.percentage) 
    22     else: 
    23         return price 
    24  
    25 register.filter('sale_price', sale_price) 
     33         
     34    if discount and discount.valid_for_product(cartitem.product): 
     35        price = calc_by_percentage(price, disc.percentage) 
     36     
     37    return price 
     38 
     39register.filter('untaxed_sale_price', sale_price) 
     40 
     41def taxed_sale_price(product): 
     42    """Returns the product unit price with the best auto discount applied and taxes included.""" 
     43    taxer = satchmo_tax._get_taxprocessor() 
     44    price = sale_price(product) 
     45    price = price + taxer.by_price(product.taxClass, price) 
     46    return price 
     47 
     48register.filter('taxed_sale_price', sale_price) 
    2649 
    2750def discount_cart_total(cart, discount): 
    28     """Returns the discounted line total for this cart item""" 
     51    """Returns the discounted total for this cart, with tax if that is the default.""" 
     52    if config_value('TAX', 'DEFAULT_VIEW_TAX'): 
     53        return taxed_discount_cart_total(cart, discount) 
     54    else: 
     55        return untaxed_discount_cart_total(cart, discount) 
     56 
     57register.filter('discount_cart_total', discount_cart_total) 
     58 
     59def untaxed_discount_cart_total(cart, discount): 
     60    """Returns the discounted total for this cart""" 
    2961    if discount: 
    3062        total = Decimal('0.00') 
     
    3769    return total 
    3870         
    39 register.filter('discount_cart_total', discount_cart_total) 
     71register.filter('untaxed_discount_cart_total', discount_cart_total) 
     72 
     73def taxed_discount_cart_total(cart, discount): 
     74    """Returns the discounted total for this cart with taxes included""" 
     75    if discount: 
     76        total = Decimal('0.00') 
     77     
     78        for item in cart: 
     79            total += taxed_discount_line_total(item, discount) 
     80    else: 
     81        total = discount_cart_total(cart, discount) 
     82         
     83    return total 
     84         
     85register.filter('taxed_discount_cart_total', discount_cart_total) 
    4086 
    4187def discount_line_total(cartitem, discount): 
     88    """Returns the discounted line total for this cart item, including tax if that is the default.""" 
     89    if config_value('TAX', 'DEFAULT_VIEW_TAX'): 
     90        return taxed_discount_line_total(cartitem, discount) 
     91    else: 
     92        return untaxed_discount_line_total(cartitem, discount) 
     93 
     94     
     95register.filter('discount_line_total', discount_line_total) 
     96 
     97def untaxed_discount_line_total(cartitem, discount): 
    4298    """Returns the discounted line total for this cart item""" 
    43     lt = cartitem.line_total 
     99    price = cartitem.line_total 
    44100    if discount and discount.valid_for_product(cartitem.product): 
    45         return calc_by_percentage(lt, discount.percentage) 
    46     else: 
    47         return lt 
    48          
    49 register.filter('discount_line_total', discount_line_total) 
     101        price = calc_by_percentage(price, discount.percentage) 
     102     
     103    return price 
     104         
     105register.filter('untaxed_discount_line_total', discount_line_total) 
     106 
     107def taxed_discount_line_total(cartitem, discount): 
     108    """Returns the discounted line total for this cart item with taxes included.""" 
     109    price = discount_line_total(cartitem, discount) 
     110    taxer = satchmo_tax._get_taxprocessor() 
     111    price = price + taxer.by_price(cartitem.product.taxClass, price) 
     112     
     113    return price 
     114         
     115register.filter('taxed_discount_line_total', discount_line_total) 
     116 
     117def discount_price(product, discount): 
     118    """Returns the product price with the discount applied, including tax if that is the default. 
     119     
     120    Ex: product|discount_price:sale 
     121    """ 
     122    if config_value('TAX', 'DEFAULT_VIEW_TAX'): 
     123        return taxed_discount_price(product, discount) 
     124    else: 
     125        return untaxed_discount_price(product, discount) 
     126 
     127 
     128register.filter('discount_price', discount_price) 
    50129    
    51 def discount_price(product, discount): 
     130def untaxed_discount_price(product, discount): 
    52131    """Returns the product price with the discount applied. 
    53132     
     
    56135    up = product.unit_price 
    57136    if discount and discount.valid_for_product(product): 
    58         return calc_by_percentage(up, discount.percentage) 
     137        pcnt = calc_by_percentage(up, discount.percentage) 
     138        return pcnt 
    59139    else: 
    60140        return up 
    61141 
    62 register.filter('discount_price', discount_price) 
     142register.filter('untaxed_discount_price', discount_price) 
     143 
     144def taxed_discount_price(product, discount): 
     145    """Returns the product price with the discount applied, and taxes included. 
     146     
     147    Ex: product|discount_price:sale 
     148    """ 
     149    price = discount_price(product, discount) 
     150    taxer = satchmo_tax._get_taxprocessor() 
     151    price = price + taxer.by_price(product.taxClass, price) 
     152 
     153register.filter('taxed_discount_price', discount_price) 
    63154 
    64155def discount_ratio(discount): 
     
    73164 
    74165def discount_saved(product, discount): 
     166    """Returns the amount saved by the discount, including tax if that is the default.""" 
     167    if config_value('TAX', 'DEFAULT_VIEW_TAX'): 
     168        return taxed_discount_saved(product, discount) 
     169    else: 
     170        return untaxed_discount_saved(product, discount) 
     171 
     172register.filter('discount_saved', discount_saved) 
     173 
     174 
     175def untaxed_discount_saved(product, discount): 
    75176    """Returns the amount saved by the discount""" 
    76177     
     
    84185        return Decimal('0.00') 
    85186 
    86 register.filter('discount_saved', discount_saved) 
    87  
    88  
     187register.filter('untaxed_discount_saved', discount_saved) 
     188 
     189def taxed_discount_saved(product, discount): 
     190    """Returns the amount saved by the discount, after applying taxes.""" 
     191     
     192    if discount and discount.valid_for_product(product): 
     193        price = product.unit_price 
     194        discounted = taxed_discount_price(product, discount) 
     195        saved = price-discounted 
     196        cents = Decimal("0.01") 
     197        return saved.quantize(cents) 
     198    else: 
     199        return Decimal('0.00') 
     200 
     201register.filter('taxed_discount_saved', discount_saved) 
  • satchmo/trunk/satchmo/discount/utils.py

    r1320 r1768  
    2020    return work.quantize(cents) 
    2121 
    22 def find_discount_for_code(code): 
     22def find_discount_for_code(code, raises=False): 
    2323    discount = None 
    2424 
     
    3030            pass 
    3131 
     32     
    3233    if not discount: 
     34        if raises: 
     35            raise Discount.DoesNotExist() 
    3336        discount = NullDiscount() 
    3437 
  • satchmo/trunk/satchmo/product/utils.py

    r1748 r1768  
    11from satchmo.configuration import config_value 
     2from satchmo.discount.utils import calc_by_percentage, find_best_auto_discount 
    23from satchmo.l10n.utils import moneyfmt 
    34from satchmo.product.models import ProductVariation, Option, split_option_unique_id, ProductPriceLookup, OptionGroup 
     
    2829            "SLUG": "Variation Slug", 
    2930            "PRICE" : {"qty" : "$price", [...]}, 
     31            "SALE" : {"qty" : "$price", [...]}, 
    3032            "TAXED" : "$taxed price",   # omitted if no taxed price requested 
    3133            "QTY" : 1 
     
    3739    config = Config.objects.get_current() 
    3840    ignore_stock = config.no_stock_checkout 
     41    discount = find_best_auto_discount(product) 
     42    use_discount = discount and discount.percentage > 0 
    3943 
    4044    if include_tax: 
     
    4246        tax_class = product.taxClass 
    4347 
    44     details = {
     48    details = {'SALE' : use_discount
    4549     
    4650    curr = config_value('SHOP', 'CURRENCY') 
     
    7377 
    7478            detail['PRICE'] = {} 
     79             
     80            if use_discount: 
     81                detail['SALE'] = {} 
     82                 
    7583            if include_tax: 
    7684                detail['TAXED'] = {} 
     85                if use_discount: 
     86                    detail['TAXED_SALE'] = {} 
    7787                 
    7888            details[key] = detail 
     
    8191         
    8292        detail['PRICE'][detl.quantity] = moneyfmt(price, curr=curr) 
     93        if use_discount: 
     94            detail['SALE'][detl.quantity] = moneyfmt(calc_by_percentage(price, discount.percentage), curr=curr) 
    8395         
    8496        if include_tax: 
    8597            tax_price = taxer.by_price(tax_class, price) + price 
    8698            detail['TAXED'][detl.quantity] = moneyfmt(tax_price, curr=curr) 
     99            detail['TAXED_SALE'][detl.quantity] = moneyfmt(calc_by_percentage(tax_price, discount.percentage), curr=curr) 
    87100                 
    88101    return details 
  • satchmo/trunk/satchmo/settings-customize.py

    r1696 r1768  
    7070    "django.contrib.auth.middleware.AuthenticationMiddleware", 
    7171    "django.middleware.doc.XViewMiddleware", 
    72     #The next middleware is required if you want to use satchmo 
    73     #to serve multiple simultaneous shops. 
    74     #"threaded_multihost.middleware.ThreadLocalMiddleware", 
     72    "threaded_multihost.middleware.ThreadLocalMiddleware", 
    7573    "satchmo.shop.SSLMiddleware.SSLRedirect", 
    7674    "satchmo.recentlist.middleware.RecentProductMiddleware", 
  • satchmo/trunk/satchmo/shop/context_processors.py

    r1562 r1768  
    77from django.conf import settings as site_settings 
    88from satchmo.product.models import Category 
     9from satchmo.discount.models import Discount 
    910from satchmo.shop import get_satchmo_setting 
    1011from satchmo.shop.models import Config, NullConfig, Cart, NullCart 
     12from satchmo.shop.signals import satchmo_context 
    1113from satchmo.utils import current_media_url, request_is_secure 
     14import datetime 
    1215import logging 
    1316 
     
    1922 
    2023    all_categories = Category.objects.by_site() 
     24     
     25    today = datetime.date.today() 
     26    discs = Discount.objects.filter(automatic=True,  
     27        active=True,  
     28        startDate__lte=today,  
     29        endDate__gt=today).order_by('-percentage') 
     30    if discs.count() > 0: 
     31        sale = discs[0] 
     32    else: 
     33        sale = None 
    2134 
    22     return
     35    ctx =
    2336        'shop_base': get_satchmo_setting('SHOP_BASE'), 
    2437        'shop' : shop_config, 
     
    3245        'login_url': site_settings.LOGIN_URL, 
    3346        'logout_url': site_settings.LOGOUT_URL, 
     47        'sale': sale 
    3448    } 
     49     
     50    satchmo_context.send(shop_config, context=ctx) 
     51     
     52    return ctx 
  • satchmo/trunk/satchmo/shop/notification.py

    r1424 r1768  
    1111from django.utils.translation import ugettext as _ 
    1212from satchmo.configuration import config_value 
     13from satchmo.discount.models import Discount 
     14from satchmo.discount.utils import find_discount_for_code 
    1315 
    1416log = logging.getLogger('contact.notifications') 
     
    2931    shop_name = shop_config.store_name 
    3032    t = loader.get_template(template) 
    31     c = Context({'order': new_order, 'shop_name': shop_name}) 
     33    try: 
     34        sale = find_discount_for_code(new_order.discount_code, raises=True) 
     35    except Discount.DoesNotExist: 
     36        sale = None 
     37         
     38    c = Context({'order': new_order, 'shop_name': shop_name, 'sale' : sale}) 
    3239    subject = _("Thank you for your order from %(shop_name)s") % {'shop_name' : shop_name} 
    3340 
  • satchmo/trunk/satchmo/shop/signals.py

    r1560 r1768  
    3535 
    3636satchmo_search = django.dispatch.Signal() 
     37 
     38satchmo_context = django.dispatch.Signal() 
     39 
  • satchmo/trunk/satchmo/static/js/satchmo_product.js

    r1719 r1768  
    11var satchmo = satchmo || {}; 
    22 
    3 // Get the current selected product price.  If taxed is true, then 
    4 // return the price inclusive of taxes. 
    5 satchmo.get_current_price = function(detail, qty, taxed) { 
    6     var k = taxed ? "TAXED" : "PRICE"; 
     3satchmo.use_sale_prices = true; 
     4 
     5// Get the current selected product price. 
     6satchmo.get_current_price = function(detail, qty, use_sale) { 
     7    var taxed = satchmo.default_view_tax, 
     8        k, prices; 
     9             
     10    if (use_sale) { 
     11        k = taxed ? "TAXED_SALE" : "SALE"; 
     12    } 
     13    else { 
     14        k = taxed ? "TAXED" : "PRICE"; 
     15    } 
     16     
    717    var prices = detail[k]; 
    818    if (prices) { 
     
    7585// update name and price based on the current selections 
    7686satchmo.update_price = function() { 
    77     var key = satchmo.make_optionkey(); 
    78     var detail = satchmo.variations[key]; 
    79     var msg = ""; 
     87    var key = satchmo.make_optionkey(), 
     88        detail = satchmo.variations[key], 
     89        msg = "", 
     90        use_sale, sale_price, full_price; 
     91         
    8092    if (detail) { 
    8193        var qty = parseInt($('#quantity').fieldValue()[0]); 
    8294        satchmo.set_name(detail['SLUG']); 
    83         var price = satchmo.get_current_price(detail, qty, satchmo.default_view_tax); 
    84         satchmo.set_price(price); 
     95         
     96        if (!satchmo.variations['SALE']) { 
     97            use_sale = false; 
     98        } 
     99        else { 
     100            use_sale = satchmo.use_sale_prices; 
     101        } 
     102 
     103        if (use_sale) { 
     104            full_price = satchmo.get_current_price(detail, qty, false); 
     105            $('#fullprice').text(full_price); 
     106 
     107            sale_price = satchmo.get_current_price(detail, qty, true); 
     108        } 
     109        else { 
     110            sale_price = satchmo.get_current_price(detail, qty, false); 
     111            $('#fullprice').hide(); 
     112        } 
     113 
     114        satchmo.set_price(sale_price); 
     115 
    85116        if (qty && qty > detail['QTY']) { 
    86117            if (detail['QTY'] == -1) { 
  • satchmo/trunk/satchmo/tax/templatetags/satchmo_tax.py

    r1699 r1768  
    88from satchmo.shop.templatetags import get_filter_args 
    99from satchmo.tax.utils import get_tax_processor 
     10from threaded_multihost.threadlocals import get_thread_variable, set_thread_variable, get_current_user 
    1011import logging 
    1112 
    1213log = logging.getLogger('satchmo.tax.templatetags') 
    1314 
    14 try: 
    15     from threading import local 
    16 except ImportError: 
    17     log.warn('getting threadlocal support from django') 
    18     from django.utils._threading_local import local 
    19  
    20 _threadlocals = local() 
    21  
    22 def set_thread_variable(key, var): 
    23     setattr(_threadlocals, key, var) 
    24      
    25 def get_thread_variable(key, default): 
    26     return getattr(_threadlocals, key, None) 
    27  
    2815register = template.Library() 
    2916 
    30 def _get_taxprocessor(request): 
     17def _get_taxprocessor(request=None): 
    3118    taxprocessor = get_thread_variable('taxer', None) 
    3219    if not taxprocessor: 
    33         user = request.user 
    34         if user.is_authenticated(): 
    35             user = user 
     20        if request:             
     21            user = request.user 
     22            if user.is_authenticated(): 
     23                user = user 
     24            else: 
     25                user = None 
    3626        else: 
    37             user = None 
     27            user = get_current_user() 
    3828 
    3929        taxprocessor = get_tax_processor(user=user)     
     
    206196    return TaxedPriceNode(price, currency, taxclass) 
    207197 
     198 
     199def with_tax(product): 
     200    """Returns the product unit price with tax""" 
     201    return taxed 
    208202     
    209203 
  • satchmo/trunk/satchmo/templates/base.html

    r1704 r1768  
    22    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    33 
    4 {% load i18n satchmo_category satchmo_google satchmo_util satchmo_currency %} 
     4{% load i18n satchmo_category satchmo_google satchmo_util satchmo_currency satchmo_discounts %} 
    55<head> 
    66    {% block extra-head %}{% endblock %} 
     
    6565 
    6666            {% if cart_count %} 
    67         ({{ cart_count }}{% if cart.total %} - {% spaceless %}{% if shop.options.TAX.DEFAULT_VIEW_TAX.value %} 
    68         {% load satchmo_tax %}{% cart_taxed_total cart 1 %}{% else %}{{ cart.total|currency }} 
    69         {% endif %}{% endspaceless %}{% endif %})<br/> 
     67        ({{ cart_count }}{% if cart.total %} - {{ cart|discount_cart_total:sale|currency }}{% endif %})<br/> 
    7068                {% url satchmo_checkout-step1 as checkouturl %} 
    7169        {% if checkouturl %}<a href="{{ checkouturl }}">{% trans "Check out" %}</a>{% endif %} 
  • satchmo/trunk/satchmo/templates/base_cart.html

    r1704 r1768  
    55{% load satchmo_util %} 
    66{% load satchmo_product %} 
     7{% load satchmo_discounts %} 
    78 
    89{% block navbar %} 
     
    2324    <th align="left">{% trans "Quantity" %}</th> 
    2425    <th>{% trans "Item" %}</th> 
     26    {% if sale %} 
     27                <th>{% trans "Regular Price" %}</th> 
     28                <th>{% trans "Sale Price" %} 
     29        {% else %} 
     30                <th>{% trans "Price" %}</th> 
     31        {% endif %} 
    2532    <th align="center">{% if default_view_tax %}{% trans "Total<br/>(incl.&nbsp;tax)" %}{% else %}{% trans "Total" %}{% endif %}</th> 
    2633    </tr> 
     
    4148            </td> 
    4249            <td><a href="{{cartitem.product.get_absolute_url}}">{{ cartitem.description }}</a></td> 
    43             <td align="center">{% cartitem_total cartitem default_view_tax %}</td> 
     50                        {% if sale %}<td align="center">{{ cartitem.product.unit_price|currency }}</td>{% endif %} 
     51                        <td align="center">{{ cartitem.product|discount_price:sale|currency }}</td> 
     52            <td align="center">{{ cartitem|discount_line_total:sale|currency }}</td> 
    4453        </tr> 
    4554                {% cartitem_custom_details cartitem %} 
    4655                {% cartitem_subscription_details cartitem %} 
    4756    {% endfor %} 
    48     <tr><td colspan="3" align="right">{% trans "Cart Total" %}:</td> 
    49         <td>{% cart_total cart default_view_tax %}</td></tr> 
     57    <tr><td colspan="{% if sale %}5{% else %}4{% endif %}" align="right">{% trans "Cart Total" %}:</td> 
     58        <td>{{ cart|discount_cart_total:sale|currency }}</td></tr> 
    5059    </table> 
    5160    {% if sale %} 
  • satchmo/trunk/satchmo/templates/base_product.html

    r1683 r1768  
    1212{% load satchmo_currency satchmo_category %} 
    1313{% load satchmo_ratings %} 
    14 {% load satchmo_util %} 
     14{% load satchmo_util satchmo_discounts %} 
    1515{% if "recentlist"|app_enabled %}{% load satchmo_recentlist %}{% endif %} 
    1616 
     
    5151<p>{{ product.translated_description }}</p> 
    5252{% trans "Price" %} {% if default_view_tax %} {% trans '(incl. tax)' %}{% endif %}: 
    53 <h3 id="price">{% if default_view_tax %}{{ price_with_tax|currency }}{% else %}{{ product.unit_price|currency }}{% endif %}</h3> 
     53<h3> 
     54        {% if sale %}<strike id="fullprice" style="display: block;">{{ product|discount_price:""|currency }}</strike>{% endif %} 
     55        <span id="price">{{ product|discount_price:sale|currency }}</span> 
     56</h3> 
    5457{% for pic in product.productimage_set.all %} 
    5558    <img src="{{ pic.picture.url|thumbnail:"width=280" }}" width="280" /> 
  • satchmo/trunk/satchmo/templates/discount/checkout_form.html

    r1259 r1768  
    33<td> 
    44{% with sale.percentage_text as pct %}{% with sale.code as code %}{% with sale.description as desc %}{% with sale.endDate|date:"y-M-d" as enddate %} 
    5 {% blocktrans %}<p>Some of the products in your cart are eligible to receive a discount of {{ pct }} when you enter the code "{{ code }}" during our {{ desc }} which ends on {{ enddate }}.</p> 
     5{% blocktrans %}<p>Products in your cart are eligible to receive a discount of {{ pct }} when you enter the code "{{ code }}" during our {{ desc }} which ends on {{ enddate }}.</p> 
    66{% endblocktrans %} 
    77{% endwith %}{% endwith %}{% endwith %}{% endwith %} 
  • satchmo/trunk/satchmo/templates/discount/some_eligible.html

    r1259 r1768  
    22<div class="saleprice"> 
    33{% with sale.percentage_text as pct %}{% with sale.code as code %}{% with sale.description as desc %}{% with sale.endDate|date:"y-M-d" as enddate %} 
    4 {% blocktrans %}<p>Some of the products on this page are eligible to receive a discount of {{ pct }} during checkout when you enter the code "{{ code }}" during our {{ desc }} which ends on {{ enddate }}.</p> 
     4{% blocktrans %}<p>Products on this page are eligible to receive a discount of {{ pct }} during checkout when you enter the code "{{ code }}" during our {{ desc }} which ends on {{ enddate }}.</p> 
    55{% endblocktrans %} 
    66{% endwith %}{% endwith %}{% endwith %}{% endwith %} 
  • satchmo/trunk/satchmo/templates/email/order_complete.txt

    r1517 r1768  
    1 {% load i18n %}{% load satchmo_currency %}{% with order.contact.first_name as first_name %}{% with order.contact.last_name as last_name %}{% blocktrans %}Dear {{ first_name }} {{ last_name }},{% endblocktrans %}{% endwith %}{% endwith %} 
     1{% load i18n satchmo_currency satchmo_discounts %}{% with order.contact.first_name as first_name %}{% with order.contact.last_name as last_name %}{% blocktrans %}Dear {{ first_name }} {{ last_name }},{% endblocktrans %}{% endwith %}{% endwith %} 
    22 
    33{% blocktrans %}Thank you for ordering with {{ shop_name }}.{% endblocktrans %} 
     
    88-------------- 
    99{% for item in order.orderitem_set.all %} 
    10 {{ item }} - {{item.unit_price|currency}} x {{item.quantity}} = {{item.sub_total|currency}} 
     10{{ item }} - {{item.product|discount_price:sale}} x {{item.quantity}} = {{item.sub_total|currency}} 
    1111{% endfor %} 
    1212 
  • satchmo/trunk/satchmo/templates/email/order_placed_notice.txt

    r1517 r1768  
    1 {% load i18n %}{% load satchmo_currency %}{% with order.contact.first_name as first_name %}{% with order.contact.last_name as last_name %}{% blocktrans %}Dear {{ first_name }} {{ last_name }},{% endblocktrans %}{% endwith %}{% endwith %} 
     1{% load i18n satchmo_currency satchmo_discounts %}{% with order.contact.first_name as first_name %}{% with order.contact.last_name as last_name %}{% blocktrans %}Dear {{ first_name }} {{ last_name }},{% endblocktrans %}{% endwith %}{% endwith %} 
    22 
    33{% with order.contact.email as email %}{% with order.contact.full_name as customer %}{% blocktrans %}Order placed on {{ shop_name }} by {{ customer }}<{{ email }}>.{% endblocktrans %}{% endwith %}{% endwith %} 
     
    66-------------- 
    77{% for item in order.orderitem_set.all %} 
    8 {{ item }} - {{item.unit_price|currency}} x {{item.quantity}} = {{item.sub_total|currency}} 
     8{{ item }} - {{item.product|discount_price:sale|currency }} x {{item.quantity}} = {{item|discount_line_total:sale|currency}} 
    99{% endfor %} 
    1010 
  • satchmo/trunk/satchmo/templates/product/detail_configurableproduct.html

    r1719 r1768  
    66{% load satchmo_currency satchmo_category%} 
    77{% load satchmo_ratings %} 
     8{% load satchmo_discounts satchmo_tax %} 
    89{% block extra-head %} 
    910 
     
    2930<h4>{{ product.translated_name }}</h4> 
    3031<p>{{ product.translated_description }}</p> 
    31 {% trans "Price" %}{% if default_view_tax %} {% trans '(incl. tax)' %}{% endif %}: <h3 id="price">{{ product.unit_price|currency }}</h3> 
     32{% trans "Price" %}{% if default_view_tax %} {% trans '(incl. tax)' %}{% endif %}: <h3>{% spaceless %} 
     33        {% if sale %}<strike style="display: block;" id="fullprice">{{ product|discount_price:""|currency }}</strike>{% endif %} 
     34        <span id="price">{{ product|discount_price:sale|currency }}</span> 
     35        {% endspaceless %}</h3> 
     36 
    3237{% for pic in product.productimage_set.all %} 
    3338    <img src="{{ pic.picture.url|thumbnail:"width=280" }}" width="280" /> 
  • satchmo/trunk/satchmo/templates/product/detail_customproduct.html

    r1424 r1768  
    11{% extends "base_product.html" %} 
    22{% load i18n %} 
    3 {% load satchmo_thumbnail %} 
     3{% load satchmo_thumbnail satchmo_discounts %} 
    44{% load satchmo_price %} 
    55{% load satchmo_currency satchmo_category%} 
    66{% load satchmo_ratings %} 
    77{% load satchmo_util %} 
     8{% load satchmo_discounts %} 
    89 
    910{% block productdetail %} 
    1011<h4>{% blocktrans with product.translated_name as name %}Custom order for {{ name }}{% endblocktrans %}</h4> 
    1112<p>{% autoescape off %}{{ product.translated_description }}{% endautoescape %}</p> 
    12 {% trans "Price" %}: <h3 id="price">{{ product.unit_price|currency }}</h3> 
     13{% trans "Price" %}: <h3>{% if sale %}<strike id="fullprice">{{ product|discount_price:""|currency }}</strike><br/>{% endif %}<span id="price">{{ product|discount_price:sale|currency }}</span></h3> 
    1314{% for pic in product.productimage_set.all %} 
    1415    <img src="{{ pic.picture.url|thumbnail:"width=280" }}" width="280" /> 
  • satchmo/trunk/satchmo/templates/search.html

    r1683 r1768  
    11{% extends "base_satchmo.html" %} 
    22{% load i18n %} 
    3 {% load satchmo_currency %} 
     3{% load satchmo_currency satchmo_discounts %} 
    44 
    55{% block navbar %} 
     
    3131                <ul> 
    3232                {% for product in results.products %} 
    33                 {% ifchanged %}<li><a href="{{ product.get_absolute_url }}">{{ product.translated_name }}</a> {% trans "for" %} {{ product.unit_price|currency}}</li>{% endifchanged %} 
     33                {% ifchanged %}<li><a href="{{ product.get_absolute_url }}">{{ product.translated_name }}</a> {% trans "for" %} {{ product|discount_price:sale|currency}}</li>{% endifchanged %} 
    3434            {% endfor %} 
    3535                </ul> 
  • satchmo/trunk/satchmo/templates/shop/_order_details.html

    r1621 r1768  
    66{% for item in order.orderitem_set.all %} 
    77{% if default_view_tax %} 
    8 {{ item }} - {{item.unit_price_with_tax|currency}} x {{item.quantity}} = {{item.total_with_tax|currency}}<br/> 
     8{{ item }} - {{item.unit_price_with_tax|currency}} x {{item.quantity}}{% if item.discount %} - {{ item.discount|currency }}{% endif %} = {{item.total_with_tax|currency}}<br/> 
    99{% else %} 
    10 {{ item }} - {{item.unit_price|currency}} x {{item.quantity}} = {{item.sub_total|currency}}<br/> 
     10{{ item }} - {{item.unit_price|currency}} x {{item.quantity}}{% if item.discount %} - {{ item.discount|currency }}{% endif %} = {{item.sub_total|currency}}<br/> 
    1111{% endif %} 
    1212{% endfor %} 
  • satchmo/trunk/satchmo/templates/shop/_order_tracking_details.html

    r1721 r1768  
    1616<h4>{% trans "Items Ordered" %}</h4> 
    1717{% for item in order.orderitem_set.all %} 
    18 {{ item }} - {{item.unit_price|currency}} x {{item.quantity}} = {{item.sub_total|currency}}<br/> 
     18{{ item }} - {{item.unit_price|currency}} x {{item.quantity}}{% if item.discount %} - {{ item.discount|currency }}{% endif %} = {{item.sub_total|currency}}<br/> 
    1919{% endfor %} 
    2020