- סטטוס
- נפתר
- דווח עבור
- WPML Multilingual & Multicurrency for WooCommerce 4.0.1
- נפתר בגרסה
- WooCommerce Multilingual 4.0.2
סקירה כללית של התקלה
הבעיה היא במוצר עם וריאציות שאינו מציג וריאציות בשפה המקורית. התרגומים של אותו מוצר מציגים את כל הווריאציות ללא בעיה.
שים לב שבעיה זו מתרחשת רק כאשר הטקסונומיה product_type מתורגמת. אין לתרגם טקסונומיה זו כלל.
שפה מקורית היא השפה שבה יצרת במקור את המוצר, ולאחר מכן תרגמת אותו משפה זו לשפות אחרות באתר שלך.
פתרון עוקף
כדי לתקן זאת, עליך לבצע את השלבים הבאים:
- הוסף את הקוד המופיע למטה לקובץ functions.php של ערכת העיצוב שלך.
- בקר באתר שלך בצד הלקוח וודא שהמוצר מוצג כעת כראוי.
- הסר את הקוד מהקובץ functions.php – אי ביצוע פעולה זו עלול לגרום לבעיות ביצועים.
function fix_product_type_terms(){
global $wpdb;
//check if terms were translated
$translations = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}icl_translations WHERE element_type = 'tax_product_type'" );
if( $translations ){
foreach( $translations as $translation ){
if( !is_null( $translation->source_language_code ) ){
//check relationships
$term_relationships = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->term_relationships} WHERE term_taxonomy_id = %d", $translation->element_id ) );
if( $term_relationships ){
$orig_term = $wpdb->get_var( $wpdb->prepare( "SELECT element_id FROM {$wpdb->prefix}icl_translations WHERE element_type = 'tax_product_type' AND trid = %d AND source_language_code IS NULL", $translation->trid ) );
if( $orig_term ){
foreach( $term_relationships as $term_relationship ){
$wpdb->update(
$wpdb->term_relationships,
array(
'term_taxonomy_id' => $orig_term
),
array(
'object_id' => $term_relationship->object_id,
'term_taxonomy_id' => $translation->element_id
)
);
}
}
}
$term_id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id = %d", $translation->element_id ) );
if( $term_id ){
$wpdb->delete(
$wpdb->terms,
array(
'term_id' => $term_id
)
);
$wpdb->delete(
$wpdb->term_taxonomy,
array(
'term_taxonomy_id' => $translation->element_id
)
);
}
}
}
foreach( $translations as $translation ){
$wpdb->delete(
$wpdb->prefix . 'icl_translations',
array(
'translation_id' => $translation->translation_id
)
);
}
}
}
add_action( 'init' , 'fix_product_type_terms' );