WPML
Статус
Решено
Заявлено для
WPML Multilingual & Multicurrency for WooCommerce 5.1.2
Решено в
WCML 5.2.0
Теги темы
Bug

Обзор проблемы

Если клиент оформляет на дополнительном языке заказ, содержащий вариативный товар WooCommerce, в заказе отображаются ID оригинального товара и ID переведенного вариативного товара. Вместо этого должны отображаться только ID оригинальных товаров.

Обходное решение

Пожалуйста, сделайте полную резервную копию Вашего сайта перед тем, как продолжить.


  1. Откройте файл …/wp-content/plugins/woocommerce-multilingual/inc/class-wcml-orders.php.

  2. Найдите строку 191.

  3. Замените:
    	private function adjust_product_item_if_translated( $item, $language_to_filter ) {
    
    		$product_id            = $item->get_product_id();
    		$translated_product_id = apply_filters( 'translate_object_id', $product_id, 'product', true, $language_to_filter );
    		if ( $product_id && $product_id !== $translated_product_id ) {
    			$item->set_product_id( $translated_product_id );
    			$item->set_name( get_post( $translated_product_id )->post_title );
    			return true;
    		}
    
    		return false;
    	}
    на:
    	private function adjust_product_item_if_translated( $item, $language_to_filter ) {
    
    		$product_id            = $item->get_product_id();
    		$translated_product_id = apply_filters( 'translate_object_id', $product_id, 'product', true, $language_to_filter );
            $variation_id           = $item->get_variation_id();
            $translated_variation_id = apply_filters( 'translate_object_id', $variation_id, 'product_variation', true, $language_to_filter );
    		if ( $product_id && $product_id !== $translated_product_id ) {
    			$item->set_product_id( $translated_product_id );
    			$item->set_name( get_post( $translated_product_id )->post_title );
    			//return true;
    		}
            if ( $variation_id && $variation_id !== $translated_variation_id ) {
                $item->set_variation_id( $translated_variation_id );
                $item->set_name( get_post( $translated_variation_id )->post_title );
                //	return true;
            }
    
    		return true;
    	}

Все известные проблемы →