WPML
الحالة
محلولة
أُبلغ عنها لـ
WPML Multilingual & Multicurrency for WooCommerce 5.5.2
تم حلها في
WPML Multilingual & Multicurrency for WooCommerce 5.5.3
وسوم الموضوع
Bug

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

قد تواجه مشكلة عند تحديث مقالة أو ترجمة تحتوي على GTIN أو UPC أو EAN أو ISBN مُدخلة في منتج WooCommerce، وستظهر رسالة:

GTIN أو UPC أو EAN أو ISBN غير صالح أو مكرر.

حل بديل مؤقت

يعمل مطورونا على هذه المشكلة وسيتم إصدار الإصلاحات قريباً.

ومع ذلك، إذا لم تتمكن من الانتظار حتى يتم إصلاح ذلك، فتأكد من أخذ نسخة احتياطية.

اذهب إلى: /wp-content/plugins/woocommerce-multilingual/inc/class-wcml-products.php
أضف هناك أسفل:

add_filter( 'wc_product_has_unique_sku', [ $this, 'check_product_sku' ], 10, 3 );

هذا الكود:
add_filter( 'wc_product_has_global_unique_id', [ $this, 'check_product_gtin' ], 10, 3 );

في أسفل الملف، أضف:
    public function check_product_gtin( $sku_found, $product_id, $sku ) {
        if ( null === $this->post_translations ) {
            $sku_found;
        }

        if ( $sku_found ) {

            $product_trid = $this->post_translations->get_element_trid( $product_id );

            $products = $this->wpdb->get_results(
                    $this->wpdb->prepare(
                            "
                SELECT p.ID
                FROM {$this->wpdb->posts} as p
                LEFT JOIN {$this->wpdb->postmeta} as pm ON ( p.ID = pm.post_id )
                WHERE p.post_type IN ( 'product', 'product_variation' )
                AND p.post_status = 'publish'
                AND pm.meta_key = '_global_unique_id' AND pm.meta_value = '%s'
             ",
                            wp_slash( $sku )
                    )
            );

            $sku_found = null;

            foreach ( (array) $products as $product ) {
                $trid = $this->post_translations->get_element_trid( $product->ID );
                if ( $product_trid !== $trid ) {
                    $sku_found = true;
                    break;
                }
            }
        }

        return $sku_found;
    }

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