Home › Forums › Ticket Products › Event Tickets Plus › Woocommerce info in CSV export?
- This topic has 13 replies, 5 voices, and was last updated 7 years, 1 month ago by Christopher.
-
AuthorPosts
-
February 13, 2017 at 1:12 am #1233690ChristopherParticipant
Hi,
Is there a way the attendee information of Woocommerce is included in the CSV export which you can get on the attendee page of an event? In the standard CSV export you only have name, email, ticket name and ID. On the order page you also have the address, but no option to export this data.
Furthermore I have set some custom fields to the Woocommerce checkout page. I was able to include them into the detail view of a single order but now I’d like to have them included in the CSV export (and probably on the general order page) as well.
I would appreciate a solution to this as I haven’t found anything that could help.
Many thanks in advance!
February 14, 2017 at 9:55 am #1234702BrookParticipantHowdy Christopher,
I would love to assist as much as I can.
This is certainly possible by using WP Filters. Checkout this example, which adds a column to the CSV export:
https://slack-files.com/T0258N5TN-F2PKQ3FD3-b58b542827
The function tribe_export_custom_add_columns () is adding column titles to the CSV export, while the function tribe_export_custom_populate_columns () is adding column data to each row. By modifying these two function you can add multiple columns, and populate them with any data you want. It will certainly take a bit of PHP knowhow, but assuming you have that or someone on staff who does, you should be able to get this accomplished no problem.
Does that all make sense?
Cheers!
– Brook
February 21, 2017 at 1:05 am #1242801ChristopherParticipantHi,
thanks for your assistance!
Am I right that this is for registered users? We only have tickets for unregistered users so there is no user_id.
Is there any documentation about the functions so I can look which attribute we should check to get woocommerce data like “billing_postcode” and custom fields?I’m sorry if this is not understandable.
February 21, 2017 at 1:42 am #1242819ChristopherParticipantJust a quick update: I got it working! Everything’s quite fine now, except one little thing:
Is it possible to exclude some columns? Things like the ticket id or security code are useless for our needs so it would be great if we could delete these columns from the csv export or if this is not possible to rearrange the order of the columns 🙂
February 23, 2017 at 2:04 am #1244375LarsParticipantHi I’m also trying to add the woocommerce info to my csv export but no luck yet. My users are also not registered, may I ask how did you got it working @Christopher? Any info would be greatly appreciated.
February 23, 2017 at 2:30 am #1244383ChristopherParticipantHi Lars,
just take the snippet you can find above and change the functions tribe_export_custom_add_columns and tribe_export_custom_populate_columns like this example:
function tribe_export_custom_add_columns ( $columns ) { $columns['wc_first_name'] = 'First Name'; $columns['wc_last_name'] = 'Last Name'; $columns['wc_address'] = 'Address'; return $columns; }
function tribe_export_custom_populate_columns ( $value, $item, $column ) { $order = new WC_Order( $item['order_id'] ); $firstname = utf8_decode($order->billing_first_name); $lastname = utf8_decode($order->billing_last_name); $address = utf8_decode($order->billing_address_1) . ' / ' . $order->billing_postcode . ' / ' . utf8_decode($order->billing_city); if ( isset($order) ) { switch ($column) { case 'wc_first_name': $value = $firstname; break; case 'wc_last_name': $value = $lastname; break; case 'wc_address': $value = $address; break; } } else { $value = '-'; } return $value; }
With this you get three additional columns in which the data of each attendee is included (only if the attendee has this data supplied).
Does this help?February 23, 2017 at 3:15 am #1244401LarsParticipantYes thank you @Christopher! Hadn’t thought about using a switch.. Great idea.
February 24, 2017 at 8:52 am #1245325BrookParticipantThat is beautiful code Cristopher. Thank you for sharing it.
Is it possible to exclude some columns? Things like the ticket id or security code are useless for our needs so it would be great if we could delete these columns from the csv export or if this is not possible to rearrange the order of the columns ?
That is definitely possible. Within the function tribe_export_custom_add_columns() you are adding columns to an array. But, you can also remove existing columns from that array. Inside the array there is a column with the key “security that you should be able to unset():
unset( $columns['security'] );
Just insert that code before the return function and the column will disappear. Do this with any columns you don’t want.
Cheers!
– Brook
February 27, 2017 at 12:39 am #1246119ChristopherParticipantHey,
Thanks!
That is exactly what I nedd.
Just one little thing: Is there a list of those keys? I’ve been searching for it but I haven’t been successful.Many thanks in advance and best regards
ChristopherFebruary 28, 2017 at 12:45 am #1246736BrookParticipantHowdy Cristopher,
The list of keys will depend on your system and which plugins you have installed. Instead of running unset() you could run var_dump($columns); and it will output a list. Or, of course you could use a debugger like x-debug. Whatever is easiest for you.
Thanks for getting back!
Cheers!
– Brook
March 2, 2017 at 2:50 am #1248238ChristopherParticipantHey Brook,
Thanks for your reply and hints, I got it working although not all of the columns could be removed, but that’s fine.
Best regards and many thanks
ChristopherMarch 3, 2017 at 6:22 am #1248915BrookParticipantIt was my pleasure to help. I’m happy to hear you were able to add what you wanted. I’m puzzled that not all of the columns could be removed, though there are some columns I’ve not tried removing myself. Perhaps the default WordPress ones were giving you difficulty? Or something else was adding them after you removed them? Whatever the case it sounds like your happy with it for now. Just let us know if you ever need anything else. Cheers!
– Brook
March 25, 2017 at 9:35 am #1259986Support DroidKeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Woocommerce info in CSV export?’ is closed to new replies.