- סטטוס
- נפתר
- דווח עבור
- 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;
}