- Status
- Waiting for author
- Related plugin/theme
- Event Tickets Plus
Overview of the issue
When you are using the Event Tickets Plus plugin to create a new event and add tickets to it, the tickets section does not appear on the translated event page.
Workaround
Please, before proceeding, make a full backup of your site:
- Add the following snippet to WPML → Settings → Custom XML Configuration:
<wpml-config> <custom-fields> <custom-field action="copy">_ticket_end_date</custom-field> <custom-field action="copy">_ticket_start_date</custom-field> <custom-field action="copy">_tribe_ticket_capacity</custom-field> <custom-field action="copy">_tribe_ticket_show_description</custom-field> <custom-field action="copy">_tribe_ticket_version</custom-field> <custom-field action="copy">_tribe_tickets_ar_iac</custom-field> <custom-field action="copy">_tribe_tickets_meta</custom-field> <custom-field action="copy-once">_tribe_wooticket_for_event</custom-field> </custom-fields> </wpml-config> - Add the following code to the functions.php file:
//WPML Workaround add_action( 'save_post', 'wpmldp_update_tribe_wooticket_for_event_meta', 999,3 ); function wpmldp_update_tribe_wooticket_for_event_meta( $post_id, $post, $update ) { // Only set for post_type = product if ( 'product' !== $post->post_type ) { return; } //Check if WPML and THe Events Calendar are enabled if (class_exists('SitePress')) { //Get the current ID on "_tribe_wooticket_for_event" meta $current_wooticket_id = get_post_meta($post_id, '_tribe_wooticket_for_event'); if ( $current_wooticket_id ) { //Get Post Language $wpml_post_language_details = apply_filters( 'wpml_post_language_details', NULL, $post_id ) ; $wpml_current_language = $wpml_post_language_details['language_code']; //Check if there is a translation for the $current_wooticket_id. If not, returns the original ID $translated_wooticket_id = apply_filters( 'wpml_object_id', $current_wooticket_id[0], 'page', FALSE, $wpml_current_language); //Update post meta with the translated ID if ($translated_wooticket_id) { update_post_meta( $post_id, '_tribe_wooticket_for_event', $translated_wooticket_id ); } } } return; } - Create the event, and add tickets to it.
- Translate the event.
- Go to Products → All Products and edit the ticket.
- Do a small modification on the ticket and save.
- Translate the ticket. Keep in mind that if the event already exists, you just need to translate it before translating the ticket. If both are already translated, do a small modification on the original ticket, then update the translation.
If you are using The Events Calendar plugin, you will need to change this line:
$translated_wooticket_id = apply_filters( 'wpml_object_id', $current_wooticket_id[0], 'page', FALSE, $wpml_current_language);To:
$translated_wooticket_id = apply_filters( 'wpml_object_id', $current_wooticket_id[0], 'tribe_events', FALSE, $wpml_current_language);
Next steps
Event Tickets Plus and WPML are not fully compatible yet, but we’d like to work collaboratively with The Events Calendar team to finalize this. If this plugin’s compatibility with WPML is important to you, please let The Events Calendar team know via their public support forum, or private support channels and we can try to push this forward together.