Overview of the Issue
When using YITH WooCommerce Request a Quote with WPML, you might experience the following issue: a product added to the quote list in one language keeps that language’s name after the visitor switches language, and adding the same product in the other language adds a second line.
The free plugin fixes this issue in version 2.56.1. The premium plugin does not have this fix yet (tested with version 4.48.0).
Workaround
Add this code to your theme’s functions.php file. It shows each product of the quote list in the current language, and it merges the lines of the same product:
PHP
add_action( 'wp', function () {
if ( ! function_exists( 'YITH_Request_Quote' ) ) { return; }
$q = YITH_Request_Quote();
$lang = apply_filters( 'wpml_current_language', null );
$list = [];
foreach ( (array) $q->raq_content as $item ) {
$pid = (int) apply_filters( 'wpml_object_id', (int) $item['product_id'], 'product', true, $lang );
$vid = empty( $item['variation_id'] ) ? '' : (int) apply_filters( 'wpml_object_id', (int) $item['variation_id'], 'product_variation', true, $lang );
$key = md5( $pid . $vid );
$item['product_id'] = $pid;
if ( '' !== $vid ) { $item['variation_id'] = $vid; }
if ( isset( $list[ $key ] ) ) { $list[ $key ]['quantity'] += (int) $item['quantity']; } else { $list[ $key ] = $item; }
}
$q->raq_content = $list;
$q->set_session( $list, true );
}, 98 );