- Status
- Gelöst
- Gemeldet für
- WPML Multilingual & Multicurrency for WooCommerce 5.5.2
- Gelöst in
- WPML Multilingual & Multicurrency for WooCommerce 5.5.3
- Themen-Tags
- Bug
Übersicht über das Problem
Möglicherweise stoßen Sie auf ein Problem beim Aktualisieren eines Beitrags oder einer Übersetzung, die eine im WooCommerce-Produkt hinterlegte GTIN, UPC, EAN oder ISBN enthalten, und es wird folgende Meldung angezeigt:
Ungültige oder duplizierte GTIN, UPC, EAN oder ISBN.
Problemumgehung
Unsere Entwickler arbeiten an dem Fall und Fehlerbehebungen werden in Kürze veröffentlicht.
Wenn Sie jedoch nicht auf die Fehlerbehebung warten können, stellen Sie sicher, dass Sie ein Backup haben.
Gehen Sie zu: /wp-content/plugins/woocommerce-multilingual/inc/class-wcml-products.php
Fügen Sie dort unterhalb von:
add_filter( 'wc_product_has_unique_sku', [ $this, 'check_product_sku' ], 10, 3 );
diesen Code hinzu:
add_filter( 'wc_product_has_global_unique_id', [ $this, 'check_product_gtin' ], 10, 3 );
Fügen Sie am Ende der Datei Folgendes hinzu:
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;
}