Packaged product

53 views
Skip to first unread message

Samuel Martin

unread,
May 10, 2016, 5:30:12 AM5/10/16
to django-oscar
Hi,

I don't understand the custom benefits behavior. 


I have 2 products in shop :

Product #id1 : Exam : 210€
Product #id2 : Training : 30 €


First case :
 When Product #id1 and Product #id2 are in basket I want to apply a discount of 30 €.


Second Case (Package):
Product #id3 : Exam + Training : 210 €
When Product #id3  is in basket  I want three line  : Product #id1 Production #id2 and discount of 30 €  , it's possible ? 


Thanks,


Regards,




Ori Hoch

unread,
May 11, 2016, 2:03:23 AM5/11/16
to django-oscar
I think the custom benefits feature is perfect for this, see: https://django-oscar.readthedocs.io/en/releases-1.1/howto/how_to_create_a_custom_benefit.html

Samuel Martin

unread,
May 11, 2016, 4:32:03 AM5/11/16
to django-oscar
I already read this article. 

Samuel Martin

unread,
May 11, 2016, 5:20:14 AM5/11/16
to django-oscar
Here's what works for me : 

class FreeTraining(models.Benefit):


   
class Meta:
        proxy
= True


    description
= "Free  Training"
   
def apply(self, basket, condition, offer=None):


        message
= u"certification pro et training absent"


        pro
= 0
        training
= 0
       
for article in  basket.all_lines():
           
if article.product_id == 212:
                pro
+=1
           
if article.product_id == 217:
                training
+=1

        condition
.consume_items(offer, basket, ())
 
       
if pro and not training:
            message
= "certification pro dans le panier"
       
if not pro and training:
            message
= "formation dans le panier"
       
if pro and training:
            message
= "certification pro et formation dans le panier"
       
return models.PostOrderAction(message)
However if I change return models.PostOrderAction to models.BasketDiscount(D('30.0')), the site spends much time. Finally I have blank page.

I don't understand how can I apply "discount" on my basket .
Reply all
Reply to author
Forward
0 new messages