WPPizza – A Restaurant Plugin for WordPress › Support › General Support › How to get list of orders with php ?
- AuthorPosts
- 6 April, 2018 at 8:12 pm #36533
hello there
im trying to develop a plugin but i couldnt managed to get orders in wp pizza, what is the right way to do this ?
also i want to add orders programmatically
i tried to get it from the database table but with that way i cant get order status etc.i couldnt find anything on docs, what class/file/document should i look into ?
6 April, 2018 at 10:39 pm #36570i’m afraid , there isnt really a simple way to do this as virtually all queries will only ever return a restricted dataset
(either by user id , or by order id , or limited by pagination etc etc)that said, i can see the usefulness of making this available in some circumstances , and will add an easy to use wrapper function in one of the next updates
7 April, 2018 at 6:30 am #36573so, how can one get users orders ? i couldnt find it in documentation
i can start from there and implement my need, and share final code with everyone7 April, 2018 at 11:49 am #36574nevermind i could to it
WPPIZZA() -> db -> get_orders_orderhistory(false, -1, 10, 1);
you can also do it with this.
i hope wp pizza had better documentation and little bit better quality of code.7 April, 2018 at 12:12 pm #36575that’s just offensive
feel free to write your own plugin, maintain it over the years keeping things backwards compatible for old php, mysql versions while also accounting for endless variations of server setup, adding forever new things for your 1000’s of users , reply to literally thousands of support requests / emails / forum topics and then come back to me complainingin any event , that get_orders_orderhistory is a leftover from v2 and is only used in the order history and will probably be removed at some point in favour of a wrapper that will then use the fetch_order_details which will then allow queries that are not as restrictive as they are at the moment with the output being formatted as opposed to just the raw data and a bunch of other options
7 April, 2018 at 1:21 pm #36577in fact i would suggest you simply use your own query
ie. something like
global $wpdb; $orders = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix . WPPIZZA_TABLE_ORDERS." WHERE payment_status='COMPLETED' ORDER BY order_date DESC");
as opposed to relying on internal functions that might change or get removed at any time (unless they are documented here https://docs.wp-pizza.com/developers/?section=filters-actions-functions , hence why there are a bunch of wrappers available the list of which gets expanded on an as needed basis )
- AuthorPosts
- The topic ‘How to get list of orders with php ?’ is closed to new replies.