Reputation: 183
I'm new to Django-oscar
and working on Basket
now
I can add products as lines to the basket easily but what if I want to choose a specific Product attribute to add to basket for example
product A has attributes {'size': ['M', 'S'], 'color': ['red', 'blue']}
what should i do if i want to add product A with size M and color blue to the basket?
Upvotes: 4
Views: 865
Reputation: 183
for those who will come looking for the same issue,
i found a way to do this:
There is an Oscar Model called Option
you can add the attributes you generally add to your items eg. Size Color Flavor ..etc
and pass the value from product's attributes
because
basket.add_product()
has options
argument and only accept Option instance so we need to have it
it's passed as list of objects in this way:
[
{'option': Option.objects.get(name="name"), 'value': 'Value'},
]
please if you know a better way to do it, comment here :)
Upvotes: 4