Displaying offer-discounted prices on the product detail page

1,189 views
Skip to first unread message

Markus Bertheau

unread,
Jul 7, 2014, 12:26:58 PM7/7/14
to django...@googlegroups.com
Hi,

on the product detail and list pages we need to display the price of the product with all applicable offers applied. Currently the components that calculate the discounted price, ConditionalOffer, Applicator and Line/Basket are pretty tightly coupled. A quick way to do what we want to do is to add the product to the basket, re-apply offers, fetch the price and remove the product from the basket again. Of course that's horribly inefficient, given that adding a product to the basket hits the database. So we're looking for an alternative in the medium term.

The general idea would be to decouple the above mentioned components. The Applicator would be given 1) a list of offers and 2) a list of product/stockrecords with quantity. It would deliver ApplicableOffers (the terminology is not final). It would do so without relying on Basket or Line functionality (e.g. currently the Line itself tracks whether it had a discount applied already). To replace the current offers calculation for the basket, a new component would 1) extract product/stockrecords with quantity from the basket, 2) extract a list of offers from various sources, 3) hand them to the Applicator and 4) apply the ApplicableOffers to the basket. On the list and detail pages 1) would be done and the current product would be added. 2) and 3) are the same and then instead of 4) just the new product's price would be extracted.

Thoughts? :)

Thanks

Markus

Michael Lind Hjulskov

unread,
Jul 10, 2014, 6:15:17 AM7/10/14
to django...@googlegroups.com
Hi Markus

A lot of simulation...
I'm not sure if this is a best solution, but on the product details site You could just point to the offers that this product is available in.
i.e. Available offers: Summer offer (get 1 free product if you buy 9 more), Brazil lost offer (get 10% discount if you buy for 19$ more)
This wouldnt make it all that complicated with all the simulations etc
And I think the customer feels its informative and simple

Michael



Med venlig hilsen
Michael Hjulskov

Mobil +45 22116322


--
https://github.com/tangentlabs/django-oscar
http://django-oscar.readthedocs.org/en/latest/
https://twitter.com/django_oscar
---
You received this message because you are subscribed to the Google Groups "django-oscar" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-oscar...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-oscar.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-oscar/74878f0d-dc68-467d-b88e-d8683b17264a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Winterbottom

unread,
Jul 15, 2014, 10:05:25 AM7/15/14
to django-oscar
​That sounds like a good change, decoupling the basket and offers application process (which, as you say, are tightly coupled).​

Seems like quite a strange requirement though. I guess it would make more sense for offers that led to a % off. For multibuy offers though, it wouldn't make sense as the effective prices depend on what else is used to meet the offer condition.

 

Thoughts? :)

Thanks

Markus

--
https://github.com/tangentlabs/django-oscar
http://django-oscar.readthedocs.org/en/latest/
https://twitter.com/django_oscar
---
You received this message because you are subscribed to the Google Groups "django-oscar" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-oscar...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-oscar.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-oscar/74878f0d-dc68-467d-b88e-d8683b17264a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
David Winterbottom
Technical Director

Tangent Snowball
84-86 Great Portland Street
London W1W 7NR
England, UK

Markus Bertheau

unread,
Jul 15, 2014, 11:48:34 AM7/15/14
to django...@googlegroups.com, david.win...@tangentlabs.co.uk


On Tuesday, July 15, 2014 4:05:25 PM UTC+2, David Winterbottom wrote:



On 7 July 2014 17:26, Markus Bertheau <markus....@machtfit.de> wrote:
Hi,

on the product detail and list pages we need to display the price of the product with all applicable offers applied. Currently the components that calculate the discounted price, ConditionalOffer, Applicator and Line/Basket are pretty tightly coupled. A quick way to do what we want to do is to add the product to the basket, re-apply offers, fetch the price and remove the product from the basket again. Of course that's horribly inefficient, given that adding a product to the basket hits the database. So we're looking for an alternative in the medium term.

The general idea would be to decouple the above mentioned components. The Applicator would be given 1) a list of offers and 2) a list of product/stockrecords with quantity. It would deliver ApplicableOffers (the terminology is not final). It would do so without relying on Basket or Line functionality (e.g. currently the Line itself tracks whether it had a discount applied already). To replace the current offers calculation for the basket, a new component would 1) extract product/stockrecords with quantity from the basket, 2) extract a list of offers from various sources, 3) hand them to the Applicator and 4) apply the ApplicableOffers to the basket. On the list and detail pages 1) would be done and the current product would be added. 2) and 3) are the same and then instead of 4) just the new product's price would be extracted.

​That sounds like a good change, decoupling the basket and offers application process (which, as you say, are tightly coupled).​

Currently I ripped out the Conditions and Benefits we don't need and refactor just the rest. I may or may not find time to implement the ripped out condition and benefit types later.

Seems like quite a strange requirement though. I guess it would make more sense for offers that led to a % off. For multibuy offers though, it wouldn't make sense as the effective prices depend on what else is used to meet the offer condition.

We'll be using it for % off benefits, indeed. However for multibuy 3 for 2 you can just display "free" when browsing the 3rd product if you already have 2 in your basket.

Markus

Florian Moussous

unread,
Jan 3, 2015, 2:48:54 PM1/3/15
to django...@googlegroups.com, mic...@hjulskov.dk
Hello!
I have a similar issue: I'd like to display available offers for a product (say on the detail page). How would it be done? I can't find the way...

Thanks !
And happy new year to everyone ^^

Markus Bertheau

unread,
Jan 5, 2015, 5:44:36 AM1/5/15
to django...@googlegroups.com, mic...@hjulskov.dk
We use this branch: https://github.com/machtfit/django-oscar/tree/refactor-offers and then this code: https://gist.github.com/mbertheau/5258bb2e64380d808e78 . line.benefits then has the applicable benefits.

Florian Moussous

unread,
Jan 5, 2015, 7:00:48 AM1/5/15
to django...@googlegroups.com
Thanks! 
But still, I’d like to link to available offers (or display them) on a product's page. I may be wrong but your code won’t allow that?

You received this message because you are subscribed to a topic in the Google Groups "django-oscar" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-oscar/nr5QFw5tPII/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-oscar...@googlegroups.com.

Raydel Miranda

unread,
Jun 20, 2018, 4:11:01 PM6/20/18
to django-oscar
I implemented this by adding the options SCOPE_BASKET and SCOPE_PRODUCT to the ConditionalOffer class. Also, add to the product a property product_discount that resolve the discount based on the offers that apply and has the proper scope. That way I'm able to show in templates something like (see attached image) :
 
{% product.price - product.product_discount %}

In the end, the totals are not affected since the offers get applied by Applicator class.
Screenshot from 2018-06-20 16-02-48.png

sh...@richkenmedia.com

unread,
Jul 28, 2018, 5:36:43 PM7/28/18
to django-oscar
Hello Raydel Miranda,
                          I am new to the Django and Oscar. I also have the same use case scenario, can you please explain me how did you get this? Or share the code on Gist? Thank you very much for your support!

Regards
Shine Mon
Reply all
Reply to author
Forward
0 new messages