discount prices applied to all products not working properly

Create issue
Issue #1162 resolved
slowpeels created an issue

I first noticed this in detail_configurableproduct.html.

The "discount_price" template tag doesn't pick up discounts that are applied to all products. The code it is calling doesn't take into consideration discounts where "allValid" is set to true.

Additionally, the javascript code for setting the sale price of configurable product fails, because apps.product.utils.find_best_discount also does not check for discounts on all products.

{{{

!python

diff -r 11767f69083b satchmo/apps/product/models.py --- a/satchmo/apps/product/models.py Thu May 27 20:44:08 2010 -0500 +++ b/satchmo/apps/product/models.py Sun May 30 13:15:45 2010 -0500 @@ -598,6 +598,8 @@ """Tests if discount is valid for a single product""" if not product.is_discountable: return False + elif self.allValid: + return True p = self.valid_products.filter(idexact = product.id) return p.count() > 0 or \ (product.slug in self._valid_products_in_categories()) diff -r 11767f69083b satchmo/apps/product/utils.py --- a/satchmo/apps/product/utils.py Thu May 27 20:44:08 2010 -0500 +++ b/satchmo/apps/product/utils.py Sun May 30 13:15:45 2010 -0500 @@ -1,5 +1,6 @@ from decimal import Decimal from django.contrib.sites.models import Site +from django.db.models import Q from livesettings import config_value from l10n.utils import moneyfmt from product.models import Option, ProductPriceLookup, OptionGroup, Discount, Product, split_option_unique_id @@ -27,7 +28,7 @@ product = (product,) today = datetime.date.today() discs = Discount.objects.filter(automatic=True, active=True, startDatelte=today, endDategt=today) - return discs.filter(valid_productsin=product).order_by('-percentage') + return discs.filter(Q(valid_products__in=product) | Q(allValid=True)).order_by('-percentage')

def find_best_auto_discount(product): discs = find_auto_discounts(product)

}}}

Comments (3)

  1. Tay Ray Chuan

    Merge in test for product.utils.find_auto_discounts

    References #1162.

    • commit '1e334e1': shop.tests: mark test for product.utils.find_auto_discounts as fixed shop.tests: add test for product.utils.find_auto_discounts

    33c68ed09c92

  2. Log in to comment