Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 1 reply, has 2 voices.

Last updated by Carlos Rojas 2 years, 10 months ago.

Assigned support staff: Carlos Rojas.

Author Posts
March 20, 2018 at 1:54 pm #1551017

maxE-6

Adding variation to the cart causes overwriting parent product title with empty in in case if variation is from other language that currently set in user's session.

in woocommerce-multilingual/inc/class-wcml-cart.php
in public function woocommerce_calculate_totals( $cart, $currency = false )
near

if ( ! is_null( $tr_variation_id ) ) {
	$cart->cart_contents[ $key ]['product_id']   = intval( $tr_product_id );
	$cart->cart_contents[ $key ]['variation_id'] = intval( $tr_variation_id );
	if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '2.7', '<' ) ) {
		$cart->cart_contents[ $key ]['data']->id = intval( $tr_product_id );
	} else {
		$cart->cart_contents[ $key ]['data']->set_id( intval( $tr_product_id ) );
	}
	$cart->cart_contents[ $key ]['data']->post = get_post( $tr_product_id );
}

$cart->cart_contents[ $key ]['data'] should keep current variation translated id ($tr_variation_id) but it overwriting with parents product id ($tr_product_id). And then this value used in WC_Product_Variation that causes other bug in woocommerce core.
hidden link

Here is other tickets that seem related to this issue.
https://wpml.org/forums/topic/ajax-add_to_cart-on-translated-product-call-empties-title-of-original-product/
https://wpml.org/forums/topic/adding-different-variations-of-a-variable-product-to-cart-deletes-the-title/

March 21, 2018 at 8:07 pm #1552944

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

Hello,
Thank you for contacting WPML support.

I will consult my colleages regarding this issue.

Have you being able to reproduce this issue in a fresh new installation?

Kind regards,
Carlos

The topic ‘[Closed] Fixing misprint that cause disappearing title of products with variations.’ is closed to new replies.