Forum Replies Created
-
AuthorPosts
-
JasonParticipant
Hi Shelby,
I’ve been searching though other parts of this forum and came across these two tickets.
https://theeventscalendar.com/support/forums/topic/woocommerce-address-field-in-csv/
https://theeventscalendar.com/support/forums/topic/woocommerce-info-in-csv-export/#dl_post-1244383
The first one looks to be very similar to what I’m trying to achieve and perhaps with a combination of the second one.
In essence, with the new custom fields that I’ve created at the checkout to capture important data according to the maker of the custom fields plugin the checkout keys (which I’ve added) have the following structure according to Right Press who made the plugin. Their storage structure is as follows
_wccf_cf_{key} field value in order meta
_wccf_cf_id_{key} field id in order meta
_wccf_cf_data_{key} extra data array in order meta
_wccf_file_{access_key} file data in order metaSo, I’ve tried amending the functions tribe_export_custom_add_columns and tribe_export_custom_populate_columns
starting with the first one taken from the above ticket I mentionedfunction tribe_export_custom_add_columns ( $columns ) {
$columns[‘wc_first_name’] = ‘First Name’;
$columns[‘wc_last_name’] = ‘Last Name’;
$columns[‘wc_address’] = ‘Address’;
return $columns;
}I’ve changed this to some fields that I’ve set up and prefixed them with the keys above
function tribe_export_custom_add_columns ( $columns ) {
$columns[‘_wccf_cf_id_emergency_medical’] = ‘Consent Emergency Medical’;
$columns[‘_wccf_cf_id_consent_marketing’] = ‘Consent Marketing’;
$columns[‘_wccf_cf_id_any_other_information’] = ‘Any other Information’;
$columns[‘_wccf_cf_id_relationship_to_child’] = ‘Relationship to Child’;
$columns[‘_wccf_cf_id_parents_email’] = ‘Parents E-mail’;
$columns[‘_wccf_cf_id_home_address’] = ‘Home Address’;
$columns[‘_wccf_cf_id_parents_name’] = ‘Parents Name’;
return $columns
}So, in essence, I’ve added the ID first.
then I’ve changed the code from the above ticket:
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;
}to my own version but this time trying to get the value from the field using the storage structure I mention above
function tribe_export_custom_populate_columns ( $value, $item, $column ) {
$order = new WC_Order( $item[‘order_id’] );
$emergencymedical = utf8_decode($order->_wccf_cf_emergency_medical);
$consentmarketing = utf8_decode($order->_wccf_cf_consent_marketing);
$anyotherinfo = utf8_decode($order->_wccf_cf_any_other_information);
$relationshiptochild = utf8_decode($order->_wccf_cf_relationship_to_child);
$parentsemail = utf8_decode($order->_wccf_cf_parents_email);
$homeaddress = utf8_decode($order->_wccf_cf_home_address);
$parentsname = utf8_decode($order->_wccf_cf_parents_name);if ( isset($order) ) {
switch ($column) {
case ’emergency_medical’:
$value = $emergencymedical;
break;
case ‘consent_marketing’:
$value = $consentmarketing;
break;
case ‘any_other_information’:
$value = $anyotherinfo;
break;
case ‘relationship_to_child’:
$value = $relationshiptochild;
break;
case ‘parents_email’:
$value = $parentsemail;
break;
case ‘home_address’:
$value = $homeaddress;
break;
case ‘parents_name’:
$value = $parents_name;
break;
}
} else {
$value = ‘-‘;
}
return $value;
}And I’ve added these to the functions.php file in my child theme and this does not work. Any ideas?
If you are unable to help me… Is there anyone that might have seen this before who can?
Many thanks
Jason
JasonParticipantHi Shelby.
But if I’m adding the attendee data to the woocommerce order (via the extension that you mentioned), how does that populate the attendee list in the export? The code that executes the “export” from the button in the backend to a csv file wouldn’t know about the additional fields at the checkout?
Thank you
Jason
JasonParticipantCould this be re-answered please? Please see my second post. Thank you.
Regards
Jason
JasonParticipantHi Jennifer, I already had that ticked.
Here is the scenario
1 Event
Multiple tickets – spanning down the page
New Customer – not logged in
Customer completes event form adding multiple tickets and answering all the questions in the extra ticket fields.
They then see the “login before purchase” option, click on it and all the information they have just added is gone after they return to the page.I either want to force them to login before they view the event page or have a way of retaining the information they just typed when they return to the page
Many thanks
Jason
-
AuthorPosts