WPML
Status
Resolved
Reported for
WPML Multilingual & Multicurrency for WooCommerce 5.5.2
Resolved in
WPML Multilingual & Multicurrency for WooCommerce 5.5.3
Topic tags
Bug

Overview of the issue

You might encounter an issue updating a post or a translation that contains GTIN, UPC, EAN or ISBN populated in the WooCommerce product and there will be a message:

Invalid or duplicated GTIN, UPC, EAN or ISBN.

Workaround

Our developers are working on the case and fixes will be issued soon.

However, if you cannot wait for this to be fixed, then make sure that you have a backup.

Go to: /wp-content/plugins/woocommerce-multilingual/inc/class-wcml-products.php
add there below:

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

this code:
add_filter( 'wc_product_has_global_unique_id', [ $this, 'check_product_gtin' ], 10, 3 );

At the bottom of the file add:
    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;
    }

All known issues →