WPML
상태
해결됨
보고된 제품
WPML Multilingual & Multicurrency for WooCommerce 5.5.2
해결된 버전
WPML Multilingual & Multicurrency for WooCommerce 5.5.3
주제 태그
Bug

문제 개요

WooCommerce 제품에 입력된 GTIN, UPC, EAN 또는 ISBN이 포함된 글이나 번역을 업데이트할 때 문제가 발생할 수 있으며 다음과 같은 메시지가 표시됩니다:

유효하지 않거나 중복된 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;
    }

알려진 모든 문제 →