django-oscar / django-oscar-api

RESTful JSON API for django-oscar

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add shipping events to the order serializer

hackeraks opened this issue · comments

I see that we have two status with respect to Orders. One per Order status which show Status of Order (IMHO show datetime of any transition) and there is another which tracks the shipping status of each orderline. In-order to show status of Order and shipment transition states like : Order placed -> packed -> shipped -> Received at Local delivery Hub -> Out for Delivery -> Delivered etc
I couldn't find this in API specifically with 'orders', which I assume that I have to implement it myself or am I missing something.
Any Help is Highly appreciated, I will be happy to implement that If this is Something that can help follow developer and is a desired feature. TY

[ { "basket": "http://127.0.0.1:8080/api/baskets/6/", "billing_address": null, "currency": "USD", "date_placed": "2020-10-10T19:26:33.808669Z", "guest_email": "", "lines": "http://127.0.0.1:8080/api/orders/3/lines/", "number": "100006", "offer_discounts": [], "owner": "http://127.0.0.1:8080/api/users/2/", "payment_url": "/api/checkout/payment-states/3/", "shipping_address": { .... }, "shipping_code": "free-shipping", "shipping_excl_tax": "0.00", "shipping_incl_tax": "0.00", "shipping_method": "Free shipping", "status": "Authorized", "total_excl_tax": "6574.45", "total_incl_tax": "6574.45", "url": "http://127.0.0.1:8080/api/orders/3/", "voucher_discounts": [] } ]

Not quite understand what your question is, but my guess is that you want to get the status of an order via the API.

The OrderSerializer contains a status field, so it should be there.

Did you chnage something in your Django settings? (eg OSCARAPI_ORDER_FIELDS) ?

The Status provide in OrderSerializer is status for an Order. What I am looking for is as below...

  1. Provide user a way to track the order i.e Status of order when was the state changed example Shipped (Currently it show order_place_date and doesn't include any transition date)
  2. Per orderline status like "Product dispatched" and subsequent transition of it. for example : "Arrived at Local Hub" next status could be "Out for delivery" etc.

All of this should have datetime and a possible comment or Note (example: Expected delivery date and time or Address not found)

I didn't change OSCARAPI_ORDER_FIELDS. TY

Ah ok, so you want to know WHEN statuses have been changed, that makes sense.

This is implemented in Oscar with Shipping Events: https://github.com/django-oscar/django-oscar/blob/01a658c44b1231fffb92db0e95c62dda7c98a704/src/oscar/apps/order/abstract_models.py#L962

We don't provide this (yet) in the API but would be really useful. So we would need to add a ShippingEvent serializer to the orders and probably orderlines, and figure out the logic for that.