2
votes

I'm working on an interface to exchange data between our OMS and WooCommerce using the Python WooCommere API Wrapper and I'm having trouble getting orders based on status. I can get all of the orders like this

tmp_orders = DIVISION_API.get('orders')

but I'm trying to get only the orders with the status of 'processing'. Based on the API documentation and the json results from the order data I get with the above call, it looks like I should be able to call

tmp_orders = DIVISION_API.get('orders', status='processing')

and only get the orders that are in the processing state, but when I try this I get the error TypeError: request() got an unexpected keyword argument 'status'.

I've looked for solid examples using Python but can't find any solution. Any suggestions would be fantastic.

Thanks.

2
@mujuonly That’s the documentation I’ve been working with, but I can’t find any example of how to get orders based on status. It’s easy enough to get by ID .get('orders/<id>') , but I can’t find anything about status. It seems odd not to have any examples for filtering based on anything other than ID.NateBrink

2 Answers

1
votes

I think I managed to figure it out. After spending quite a bit of time searching and trial and error, this looks like a workable solution.

orders = api_obj.get('orders', params={'per_page': 10, 'status': 'processing', 'page': 1})

It appears that you can pass a dict of parameters (as params) and it gets passed to the underlying request. I don't know if that's the way that the API wrapper developer intended it to be used, but it works reliably. Hope this will help someone else.

0
votes

Not familiar with that API, but from what the documentation states you should perform the .get('orders'), use .json() on the response to get the info in json format and then you can search for orders that have the key status equal to processing.