toothie
toothie

Reputation: 1029

Get shipping address for a basket in django oscar

I am writing a view for oscar. I have the 'basket' object. How do I access the shipping_address for the basket?

Upvotes: 1

Views: 1329

Answers (2)

shad0w_wa1k3r
shad0w_wa1k3r

Reputation: 13372

You should be overriding the Repository.get_available_shipping_methods as recommended.

For a dynamic implementation, you can refer to AbstractWeightBased shipping method.

You may also want to checkout django-oscar-shipping for their implementation / code

Upvotes: 1

Anentropic
Anentropic

Reputation: 33873

There is no shipping address for the basket, there's no shipping address until it becomes an order.

You can see this from the models:

https://github.com/django-oscar/django-oscar/blob/1.0.1/oscar/apps/basket/abstract_models.py
grep for 'ship'... no matches

https://github.com/django-oscar/django-oscar/blob/1.0.1/oscar/apps/order/abstract_models.py#L68
AbstractOrder model has a foreign key to order.ShippingAddress model

Upvotes: 1

Related Questions