WPPizza – A Restaurant Plugin for WordPress › Support › General Support › Adding Category to export
- AuthorPosts
- 29 November, 2018 at 2:02 pm #40350
Hi,
I’m trying to edit the CSV-Export. I need to export an additional column which contains the category and parent category of each item. Tried editing the subpage.reports.php but I don’t seem to find the correct query, that’s why I’m asking for your support.
Thanks in advance!
Best regards!
29 November, 2018 at 2:38 pm #40352may i suggest this resource
https://docs.wp-pizza.com/developers/?section=create-your-own-sales-reportas all that data – and more -exists already
(see especially the wppizza_filter_report_datasets and wppizza_filter_reports_export_results filter hooks)PS: it seems to me you are also editing core files – that is never good idea
3 December, 2018 at 1:38 pm #40425Thanks for your help, but I can’t get it working.
I’m trying to create a list of all orders, ordered by category. Doesn’t matter if it’s a CSV Export or a table on a single page. Maybe there is an easier way to achieve this? Could you please give me another hint?
Thanks in advance!
3 December, 2018 at 6:57 pm #40426perhaps the following would be simpler in this case
https://docs.wp-pizza.com/developers/?section=function-wppizza_get_ordersi.e something along these lines
$args = array( 'query'=>array( 'payment_status' => 'COMPLETED',//get completed orders only ), ); $orders = wppizza_get_orders($args); /* items for each order */ foreach($orders['orders']['items'] as $item){ //$item['cat_id_selected'] => [int] category id the item was in when it was added to cart (as an item can belong to multiple categories) //$item['item_in_categories'] => [array] all categories an item belongs to (where key -> cat id) /* do some grouping by catid i would think here , or whatever it is you need to do */ }
5 December, 2018 at 4:53 am #40465correction:
the foreach loop above should be nested – i.e something like$args = array( 'query'=>array( 'payment_status' => 'COMPLETED',//get completed orders only ), ); $data = wppizza_get_orders($args); foreach($data['orders'] as $order){ foreach($order['order']['items'] as $item){ //$item['cat_id_selected'] => [int]... //$item['item_in_categories'] => [array] ... } }
to loop through each item of each order
sorry about that
5 December, 2018 at 7:19 am #40469Hi Olly
thanks for that details and the correction. At the moment, I don‘t know how to implement that for getting output on a single page. Can you help me to get started?
Best regards!
5 December, 2018 at 11:41 am #40471you mean you don’t know how to echo/print (i.e output) things in php ?
5 December, 2018 at 11:58 am #40472😉
No, it’s not that bad! I do know how to echo / print etc. things in php. I just don’t know, where to put that code. Should I create a new php file or should I modify an existing one. Putting the code on a new wordpress-site or post will not work, I think.Sorry for the confusion and thank you!
6 December, 2018 at 4:24 am #40484you need to familiarise yourself with wordpress action and filters and generally really how it does things (see the wp codex)
perhaps something like this in your themes functions php (just as an example, there are a million ways of doing this)add_action('wp', 'my_export_function_name'); function my_export_function_name(){ global $post; if($post->ID == [some post/page id]){ /* run the query and print the output or some script that automatically creates and downloads the csv or whatever else it is you need to do */ } }
but please note: this is about the basics of wordpress, i cannot really offer support for this sort of thing in general
some basic action/filter overview can also be found here: https://docs.wp-pizza.com/developers/?section=filters-actions-functions
- AuthorPosts
- The topic ‘Adding Category to export’ is closed to new replies.