WPML
状态
等待作者
相关插件/主题
Event Tickets Plus

问题概述

当您使用 Event Tickets Plus 插件新建事件并向其中添加门票时,门票部分不会显示在翻译后的事件页面上。

临时解决方法

在继续操作之前,请对您的站点进行完整备份:

  1. 将以下代码段添加到 WPML设置自定义 XML 配置
     <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>
  2. 将以下代码添加到 functions.php 文件中:
     
    //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;
    }
  3. 创建事件,并向其添加门票。
  4. 翻译该事件。
  5. 转到产品所有产品并编辑该门票。
  6. 对门票进行少量修改并保存。
  7. 翻译门票。请注意,如果事件已经存在,您只需在翻译门票之前翻译事件。如果两者都已翻译,请对原始门票进行少量修改,然后更新翻译。

如果您使用的是 The Events Calendar 插件,您需要将此行:

 $translated_wooticket_id = apply_filters( 'wpml_object_id', $current_wooticket_id[0], 'page', FALSE, $wpml_current_language); 
更改为:
 $translated_wooticket_id = apply_filters( 'wpml_object_id', $current_wooticket_id[0], 'tribe_events', FALSE, $wpml_current_language); 

后续步骤

Event Tickets Plus 和 WPML 尚未完全兼容,但我们希望与 The Events Calendar 团队合作以最终解决此问题。如果该插件与 WPML 的兼容性对您很重要,请通过他们的公共支持论坛私有支持渠道告知 The Events Calendar 团队,我们可以尝试共同推进此工作。

所有已知问题 →