WPML
الحالة
محلولة
أُبلغ عنها لـ
WPML Multilingual & Multicurrency for WooCommerce 4.0.1
تم حلها في
WooCommerce Multilingual 4.0.2

نظرة عامة على المشكلة

تكمن المشكلة في منتج بمتغيرات لا يعرض المتغيرات في اللغة الأصلية. تعرض ترجمات ذلك المنتج جميع المتغيرات دون مشكلة.

يُرجى ملاحظة أن هذه المشكلة تحدث فقط عند ترجمة التصنيف product_type. يجب ألا يُترجم هذا التصنيف على الإطلاق.

اللغة الأصلية هي اللغة التي أنشأت المنتج بها في الأصل، ثم ترجمته من تلك اللغة إلى لغات أخرى في موقعك.

حل بديل مؤقت

لإصلاح ذلك، اتبع الخطوات التالية:


  1. أضف الكود الموجود أدناه إلى ملف functions.php في قالبك.

  2. زُر موقعك في الواجهة الأمامية وتحقق من عرض المنتج بشكل صحيح الآن.

  3. أزل الكود من ملف 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' );

جميع المشاكل المعروفة →