Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Woocommerce - Cart widget not translated on language change #803

Open
spleen1981 opened this issue Mar 12, 2020 · 4 comments
Open

Woocommerce - Cart widget not translated on language change #803

spleen1981 opened this issue Mar 12, 2020 · 4 comments
Labels
module: WC Integration with Woo Commerce

Comments

@spleen1981
Copy link
Contributor

"Cart widget": seems to be stored in sessionStorage, so a change of language won't be applied to this widget content, which will be still shown in the previous language. Modifying the cart content fixes the content language to current.

@herrvigg herrvigg added the plugin: others Concerns integration with other plugins label Mar 21, 2020
@herrvigg
Copy link
Collaborator

Another issue with the cart: #645 but this looks like different problems.

@pjrobertson
Copy link
Contributor

Confirmed, although I'd consider it low priority. The likelihood of a user switching languages only when they've reached the cart is pretty low, although not impossible of course.

@starmidopro
Copy link

starmidopro commented Jul 27, 2020

Hi i found fix for this in github @pjrobertson it fix this issue in WooCommerce like cart and checkout i test it it work with q-translate x
Maybe will be useful https://github.com/intermedi8/IM8-qTranslate-WooCommerce/blob/master/im8-qtranslate-woocommerce.php

@herrvigg herrvigg added module: WC Integration with Woo Commerce and removed plugin: others Concerns integration with other plugins labels Dec 27, 2020
@JoseManuelFV
Copy link

In case someone has the same problem and has WPML as translation plugins...
Just add this in your JS file.

This code simply forces the reloading of the fragments if the language is different from your new variable

jQuery(document).ready(function(){
	if(getCookie('wp-wpml_current_language') != localStorage.getItem("wp-wpml_current_language")){
		jQuery( document.body ).trigger( 'wc_fragment_refresh' );
		localStorage.setItem("wpml_current_language",getCookie('wp-wpml_current_language'));
	}
});

function getCookie(c_name) {
	var c_value = document.cookie,
		c_start = c_value.indexOf(" " + c_name + "=");
	if (c_start == -1) c_start = c_value.indexOf(c_name + "=");
	if (c_start == -1) {
		c_value = null;
	} else {
		c_start = c_value.indexOf("=", c_start) + 1;
		var c_end = c_value.indexOf(";", c_start);
		if (c_end == -1) {
			c_end = c_value.length;
		}
		c_value = unescape(c_value.substring(c_start, c_end));
	}
	return c_value;
}

If you use another plug-in, find where that plug-in saves the current language in javascript (they usually do).
Then replace getCookie('wp-wpml_current_language') by the corresponding value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: WC Integration with Woo Commerce
Projects
None yet
Development

No branches or pull requests

5 participants