Wednesday, August 17, 2011

Easy solution to Satchmo Discounts malfunction.

Problem:
When applying a discount only to a number of products in the store, the message advertising the discount is shown in all the products (not only the ones which the discount is applicable to).

Solution: (as seen here)

1. Go to the product view: product/views/__init__.py
2. After context = RequestContext(request,extra_context) add this line:
context['sale']=best_discount

So your function to get the template context from the Product is like:

# Get the template context from the Product.
extra_context = product.add_template_context(context=extra_context,
request=request, selected_options=selected_options,
default_view_tax=default_view_tax)

template = find_product_template(product, producttypes=subtype_names)
context = RequestContext(request, extra_context)

context['sale']=best_discount #line added

3. Done.

No comments:

Post a Comment